PHP code example of divineomega / exiguous-ecommerce

1. Go to this page and download the library: Download divineomega/exiguous-ecommerce 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/ */

    

divineomega / exiguous-ecommerce example snippets


$category = \DivineOmega\ExiguousEcommerce\Category::findBySlug("fluffy-things");
$products = $category->products();

foreach($products as $product) {
    echo $product->data->name;
}

$product = \DivineOmega\ExiguousEcommerce\Product::findBySlug("teddy-bear");
$categories = $product->categories();

$mainCategoryName = $categories[0]->data->name;

$product = \DivineOmega\ExiguousEcommerce\Product::findBySlug("teddy-bear");

$basket = \DivineOmega\ExiguousEcommerce\Basket::findCurrent();

$basket->addProduct($product); // Add one Teddy Bear

$basket->addProduct($product, 2); // Add another two Teddy Bears!

var_dump($basket->items); // Outputs an array of, you guessed it, basket items! ^_^

// ^ This would show 1 basket item with a quantity of 3 teddy bears.


$product = \DivineOmega\ExiguousEcommerce\Product::findBySlug("teddy-bear");

$basket = \DivineOmega\ExiguousEcommerce\Basket::findCurrent();

$basket->removeProduct($product); // Removes all teddy bears from the basket

$product = \DivineOmega\ExiguousEcommerce\Product::findBySlug("teddy-bear");

$basket = \DivineOmega\ExiguousEcommerce\Basket::findCurrent();

$basket->addProduct($product); // Add one Teddy Bear

$basket->setProductQuantity($product, 10); // Set the number of Teddy Bears in the basket to ten

$basket->offsetProductQuantity($product, 10); // Add ten more Teddy Bears

$basket->offsetProductQuantity($product, -5); // Remove five of those Teddy Bears

$basket = \DivineOmega\ExiguousEcommerce\Basket::findCurrent();

$basket->convertToOrder();


// Retrieves settings from the core.json file within the .settings directory
$coreSettings = \DivineOmega\ExiguousEcommerce\Settings::find('core');

echo $coreSettings->data->primaryCurrency; // Output the ecommerce's primary currency setting