Пример #1
0
 public static function getCart()
 {
     $sessionCart = array();
     $displayCart = array();
     if (getDI()->get('session')->has(self::BULL_CART_KEY)) {
         $sessionCart = json_decode(getDI()->get('session')->get(self::BULL_CART_KEY), true);
         foreach ($sessionCart as $providerId => $cartArray) {
             $cart = new Cart\Cart();
             $cart->importJson(json_encode($cartArray));
             $displayCart[$providerId] = $cart;
         }
     }
     return $displayCart;
 }
Пример #2
0
//apply the automatic discount, if pre-conditions validate
if ($compare1->isValid($shipmentA)) {
    $discountA->setShipment($shipmentA);
    $cart->setDiscount($discountA);
}
//check pre-conditions and target conditions
if ($compare3->isValid($itemA) && $compare2->isValid($itemB)) {
    $discountB->setItem($itemB);
    $cart->setDiscount($discountB);
}
echo print_r($cart->getTotals(), 1);
echo "==============" . PHP_EOL;
echo print_r($cart->getDiscountedTotals(), 1);
echo print_r($cart->getDiscountGrid());
$cart2 = new Cart\Cart();
$cart2->importJson($cart->toJson());
echo "\n{$cart2}\n";
echo print_r($cart2->getTotals(), 1);
echo print_r($cart2->getDiscountedTotals(), 1);
/**
 * @backupGlobals disabled
 */
class testSample extends PHPUnit_Framework_TestCase
{
    public function testDefault()
    {
        $expected = true;
        $actual = false;
        $this->assertEquals($expected, $actual);
    }
}