PHP code example of chuckbe / chuckcms-module-ecommerce

1. Go to this page and download the library: Download chuckbe/chuckcms-module-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/ */

    

chuckbe / chuckcms-module-ecommerce example snippets


php artisan vendor:publish --tag=chuckcms-module-ecommerce-public --force

php artisan migrate
 $cartItem->id 

        // NEW CART ITEM
        // TAXED            = TRUE
        // UNIT BASE        = 4.00          =           $ITEM->PRICE
        // TAXRATE          = 21            =           $ITEM->TAXRATE
        // UNIT EXTRAS      = 2.12          =           $ITEM->EXTRAS->TOTAL
        // UNIT RAW         = 6.120000      =           UNIT BASE + UNIT EXTRAS
        // UNIT             = 6.12          =           round(UNIT RAW)
        // QTY              = 6             =           $ITEM->QTY
        
        // TOTAL BASE       = 24.00         =           QTY * UNIT BASE
        // TOTAL EXTRAS     = 12.72         =           QTY * UNIT EXTRAS
        // TOTAL RAW        = 36.720000     =           QTY * UNIT RAW
        // TOTAL            = 36.72         =           QTY * UNIT
        
        // DISCOUNT BASE    = 2.400         =           calculateDiscount(TOTAL BASE)
        // DISCOUNT EXTRAS  = 1.272         =           calculateDiscount(TOTAL EXTRAS)
        // DISCOUNT RAW     = 3.672         =           calculateDiscount(TOTAL RAW)
        // DISCOUNT         = 3.67          =           round(calculateDiscount(TOTAL))
        
        // FINAL BASE       = 21.60         =           round(TOTAL BASE - DISCOUNT BASE)
        // FINAL EXTRAS     = 11.45         =           round(TOTAL EXTRAS - DISCOUNT EXTRAS)
        // FINAL RAW        = 33.048        =           TOTAL RAW - DISCOUNT RAW
        // FINAL            = 33.05         =           round(TOTAL RAW - DISCOUNT RAW)
        
        // TAX BASE         = 3.75          =           round( TAX BASE RAW )
        // TAX BASE RAW     = 3.74876033    =           ((TOTAL BASE - DISCOUNT BASE) / (100 + TAXRATE)) * TAXRATE
        // TAX EXTRAS       = 0.65          =           round( TAX EXTRAS RAW )
        // TAX EXTRAS RAW   = 0.65026415    =           ((TOTAL EXTRAS - DISCOUNT EXTRAS) / (100 + TAXRATE)) * TAXRATE
        // TAX RAW          = 4.40          =           TAX BASE RAW + TAX EXTRAS RAW
        // TAX              = 4.40          =           round(TAX RAW)
        
        // TAX RATES        = [21, 6]       =           taxRates()
        // TAX FOR RATE[21] = 3.75          =           taxForRate(21)
        // TAX FOR RATE[6]  = 0.65          =           taxForRate(6)