PHP code example of phil / commerce-bundle

1. Go to this page and download the library: Download phil/commerce-bundle 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/ */

    

phil / commerce-bundle example snippets


use Phil\CommerceBundle\Domain\Model\Order;
use Phil\CommerceBundle\Domain\ValueObject\PricingContext;
use Phil\CommerceBundle\Domain\ValueObject\SellableReference;
use Phil\Money\Currency;

// $modifier: Phil\CommerceBundle\Application\OrderModifier, from the container
$order = Order::open('2026-0001', Currency::of('CAD'));
$modifier->add($order, SellableReference::of('product', 'dice'), 1, PricingContext::of(1, $now));
$modifier->changeTaxZone($order, 'QC');
$order->total(); // the lines, then GST and QST on each line

$limiter = new PaymentAttemptLimiter(PaymentAttemptPolicy::of(5, 30, 900));
$key = PaymentAttemptKey::forOrder($order->number);
$decision = $limiter->decide($store->find($key), $now);