1. Go to this page and download the library: Download moltin/php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// return a list of your products
$moltin->products->all();
// return your brands
$moltin->brands->all();
// return your categories
$moltin->categories->all();
// return your collections
$moltin->collections->all();
// return your files
$moltin->files->all();
$moltin->products->get($productID);
$moltin->categories->tree();
// limit the number of resources returned:
$moltin->products->limit(10)->all();
// offset the results (page 2):
$moltin->products->limit(10)->offset(10)->all();
// order by `name`:
$moltin->products->sort('name')->all();
// reversed:
$moltin->products->sort('-name')->all();
// create relationships between resources:
$moltin->products->createRelationships($productID, 'categories', [$categoryID]);
// delete a relationship between resources:
$moltin->products->deleteRelationships($productID, 'categories', [$categoryID]);
// (Or an update with an empty array achieves the same result if you're so inclined):
$moltin->products->updateRelationships($productID, 'categories', []);
// create a file from a local disk
$moltin->files->create(['public' => 'true', 'file' => '/path/to/file.jpg']);
// create a file from a URL (note: this will download the file to your local disk then upload)
$moltin->files->create(['public' => 'true', 'file' => 'https://placeholdit.imgix.net/~text?&w=350&h=150']);
// get all integration logs for your store:
$logs = $moltin->integrations->getLogs()->data();
// get all jobs for an integration:
$jobs = $moltin->integrations->getJobs($integrationID)->data();
// get all logs for job:
$logs = $moltin->integrations->getLogs($integrationID, $jobID)->data();
// get all
$gateways = $moltin->gateways->all();
// update
$moltin->gateways->update('stripe', [
'data' => [
'enabled': true,
'login': 'your_stripe_login'
]
])
$cartReference = 'a_unique_refeference'; // supply a custom cart reference
$moltin->cart($cartReference)->addProduct($productID); // adds 1 x $productID
$moltin->cart($cartReference)->addProduct($productID, 3); // adds 3 x $productID (now has 4)
$moltin->cart()->addProduct($productID);
foreach($moltin->cart()->items() as $item) {
$cartItemID = $item->id;
// ... do something
echo $item->name . "\n";
}
$moltin->cart()->updateItemQuantity($cartItemID, 2); // now has 2
$moltin->cart()->removeItem($cartItemID);
$customer = [
// ... customer data
];
$billing = [
// ... billing data
];
$shipping = [
// ... shipping data
];
$order = $moltin->cart($cartReference)->checkout($customer, $billing, $shipping);
$gatewaySlug = 'stripe'; // the slug of your payment gateway
$paymentMethod = 'purchase'; // the order payment method (purchase is supported for now)
$params = []; // payment params (these will vary depending on the gateway, check out the example for Stripe and the docs for others)
$payment = $order->pay($gatewaySlug, $paymentMethod, $params);
try {
$moltin->products->all();
} catch (Exception $e) {
// do something with $e
}
./ProductList.php
./ProductList.php format=json
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.