/**
  * Constructor
  *
  * @param SteerShopOrder Order object
  */
 public function __construct(rtShopCartManager $cm)
 {
     if ($cm->getOrder()->isNew()) {
         throw new Exception('rtShopOrder object can\'t be new');
     }
     $this->_cart_manager = $cm;
 }
Exemplo n.º 2
0
    ?>
      
    <tr>
      <td colspan="4"><?php 
    echo __('Shipping rate');
    ?>
:</td>
      <td><?php 
    echo $rt_shop_order->getShippingCharge() != false ? format_currency($rt_shop_order->getShippingCharge(), sfConfig::get('app_rt_currency', 'USD')) : __('undefined');
    ?>
</td>
    </tr>
    <?php 
    $includes_message = '';
    if (sfConfig::get('app_rt_shop_tax_rate', 0) > 0 && sfConfig::get('app_rt_shop_tax_mode') == 'inclusive') {
        $includes_message = sprintf('(includes %s tax)', format_currency(rtShopCartManager::calcTaxComponent($rt_shop_order->getTotalCharge()), sfConfig::get('app_rt_currency', 'USD')));
    }
    ?>
    <tr>
      <td colspan="4"><?php 
    echo __('Total');
    ?>
 <?php 
    echo $includes_message;
    ?>
:</td>
      <td><?php 
    echo format_currency($rt_shop_order->getTotalCharge(), sfConfig::get('app_rt_currency', 'USD'));
    ?>
</td>
    </tr>
    $stock1tovar2->setVariationId($var2->getId());
    $stock1tovar2->save();
    $stock2tovar1 = new rtShopStockToVariation();
    $stock2tovar1->setStockId($stock2->getId());
    $stock2tovar1->setVariationId($var1->getId());
    $stock2tovar1->save();
    $stock2tovar2 = new rtShopStockToVariation();
    $stock2tovar2->setStockId($stock2->getId());
    $stock2tovar2->setVariationId($var2->getId());
    $stock2tovar2->save();
} catch (Exception $e) {
    throw new sfException('Stocks could not be added to variations! Please check.');
}
// Create cart manager instance
try {
    $cm = new rtShopCartManager();
} catch (Exception $e) {
    throw new sfException('Cart manager instance could not be created! Please check.');
}
// Add stocks to cart manager
$cm->addToCart($stock1, 2);
$cm->addToCart($stock2, 2);
// Create voucher
$voucher1 = $tools->createVoucher('Voucher $100.00 // Valid if total >= $150', 100, 'dollarOff', 150);
$voucher2 = $tools->createVoucher('Voucher $100.00 // Valid if total >= $100', 100, 'dollarOff', 100);
$voucher3 = $tools->createVoucher('Voucher 10.00% // Valid if total >= $150', 10, 'percentageOff', 150);
$voucher4 = $tools->createVoucher('Voucher 10.00% // Valid if total >= $100', 10, 'percentageOff', 100);
$t->comment('');
$t->diag('***************************************');
$t->diag('*** Voucher #1 details');
$t->diag('***************************************');
Exemplo n.º 4
0
$cm->addToCart($stock1, 1);
$cm->addToCart($stock2, 1);
// Voucher
$cm->setVoucherCode($voucher4->getCode());
$t->is($cm->getVoucherCode(), $voucher4->getCode(), '::getVoucherCode() returns correct voucher code');
$t->is($cm->getVoucherReduction(), 0.0, '::getVoucherReduction() returns 0.0 for no voucher applied');
//// Totals
$t->is($cm->getItemsCharge(), 280, '::getItemsCharge() returns the correct value');
$t->is($cm->getSubTotal(), 280, '::getSubTotal() returns the correct value');
$t->is($cm->getPreTotalCharge(), 300, '::getPreTotalCharge() returns the correct value');
$t->is($cm->getTotalCharge(), 300, '::getTotalCharge() returns the correct value');
$t->diag('4.7.3 Use valid voucher *****************************************************');
// Clean order and reset cart manager
unset($cm);
rtShopOrderTestTools::cleanOrder();
$cm = new rtShopCartManager();
// Add stocks to cart manager
$cm->addToCart($stock1, 1);
$cm->addToCart($stock2, 1);
// Voucher
$cm->setVoucherCode($voucher2->getCode());
$t->is($cm->getVoucherCode(), $voucher2->getCode(), '::getVoucherCode() returns correct voucher code');
$t->is($cm->getVoucherReduction(), 10, '::getVoucherReduction() returns correct voucher reduction');
//// Totals
$t->is($cm->getItemsCharge(), 280, '::getItemsCharge() returns the correct value');
$t->is($cm->getSubTotal(), 280, '::getSubTotal() returns the correct value');
$t->is($cm->getPreTotalCharge(), 300, '::getPreTotalCharge() returns the correct value');
$t->is($cm->getTotalCharge(), 290, '::getTotalCharge() returns the correct value');
/**
 * rtShopOrderTestTools Class
 */
sfConfig::set('app_rt_shop_shipping_charges', array('default' => 20, 'AU' => 10));
// Create tools instance
$tools = new rtShopComplexOrder1TestTools();
// Add product promotions
$productpromo1 = $tools->createProductPromotion($stock3->getRtShopProduct()->getId(), 'Promotion 10% - ' . $stock3->getRtShopProduct()->getTitle(), 10, 'percentageOff', true);
$productpromo2 = $tools->createProductPromotion($stock4->getRtShopProduct()->getId(), 'Promotion 10% - ' . $stock4->getRtShopProduct()->getTitle(), 10, 'percentageOff', false);
$productpromo3 = $tools->createProductPromotion($stock5->getRtShopProduct()->getId(), 'Promotion 10% - ' . $stock5->getRtShopProduct()->getTitle(), 10, 'percentageOff', true);
$productpromo4 = $tools->createProductPromotion($stock6->getRtShopProduct()->getId(), 'Promotion 10% - ' . $stock6->getRtShopProduct()->getTitle(), 10, 'percentageOff', false);
$productpromo5 = $tools->createProductPromotion($stock7->getRtShopProduct()->getId(), 'Promotion 10% - ' . $stock7->getRtShopProduct()->getTitle(), 10, 'percentageOff', false);
// Add cart promotion
$cartpromo1 = $tools->createCartPromotion('Cart Promotion 10%', 10, 400, 600);
// Add voucher
$voucher1 = $tools->createVoucher('Voucher $10', 10, 'dollarOff', 400, 600);
// Create cart manager instance
try {
    $cm = new rtShopCartManager();
} catch (Exception $e) {
    throw new sfException('Cart manager instance could not be created! Please check.');
}
// Add stocks to cart manager
$cm->addToCart($stock1, 2);
$cm->addToCart($stock2, 2);
$cm->addToCart($stock3, 2);
$cm->addToCart($stock4, 2);
$cm->addToCart($stock5, 2);
$cm->addToCart($stock6, 2);
$cm->addToCart($stock7, 2);
// Add addresses to order
$tools->addAddressForOrder($cm->getOrder()->getId());
$tools->addAddressForOrder($cm->getOrder()->getId(), 'shipping');
// Loop through stocks in order
// Pre total
$t->is($cm->getPreTotalCharge(), 140.0, 'PreTotal:    ' . format_currency($cm->getPreTotalCharge(), sfConfig::get('app_rt_currency', 'USD')));
$t->comment('-----------------------------------------------------------------------------');
// Voucher
$cm->setVoucherCode($voucher1->getCode());
$t->is($cm->getVoucherReduction(), 130, 'Voucher:    -' . format_currency($cm->getVoucherReduction(), sfConfig::get('app_rt_currency', 'USD')) . ' (#' . $cm->getVoucherCode() . ')');
$t->comment('=============================================================================');
// Total
$t->is($cm->getTotalCharge(), 10.0, 'Total:        ' . format_currency($cm->getTotalCharge(), sfConfig::get('app_rt_currency', 'USD')));
$t->comment('=============================================================================');
// ==============================================================================================================================
unset($cm);
rtShopComplexOrder5TestTools::cleanOrder();
// Create new cart manager instance
try {
    $cm = new rtShopCartManager();
} catch (Exception $e) {
    throw new sfException('Cart manager instance could not be created! Please check.');
}
// Add product promotions
$productpromo1 = $tools->createProductPromotion($stock3->getRtShopProduct()->getId(), 'Promotion 10% - ' . $stock3->getRtShopProduct()->getTitle(), 10, 'percentageOff', true);
// Add cart promotion
$cartpromo1 = $tools->createCartPromotion('Cart Promotion 20%', 20);
// Add voucher
$voucher1 = $tools->createVoucher('Voucher $130', 130, 'dollarOff');
// Voucher manager
$vm = $cm->getVoucherManager();
// Add gift voucher to session
$welcome_voucher = $tools->createGiftVoucherDataArray(50);
$vm->setSessionVoucherArray($welcome_voucher);
$gift_voucher = $vm->persistSessionVoucher();
$t->is($cm->getTotalCharge(), 0, 'Total (includes $' . format_currency($cm->getTaxComponent(), sfConfig::get('app_rt_currency', 'USD')) . ' tax): ' . format_currency($cm->getTotalCharge(), sfConfig::get('app_rt_currency', 'USD')));
$t->comment('=============================================================================');
$cm->adjustVoucherDetails($cm->getPreTotalCharge());
$t->is($cm->getVoucher()->getReductionValue(), 30, '>>> Voucher leftover after reduction value: ' . format_currency($cm->getVoucher()->getReductionValue(), sfConfig::get('app_rt_currency', 'USD')) . ' <<<');
$t->diag('');
$t->diag('/////////////////////////////////////////////////////////////////////////////');
$t->diag('2. Voucher: 10%, non-stackable');
$t->diag('/////////////////////////////////////////////////////////////////////////////');
// Clean order and reset cart manager
unset($cm);
rtShopComplexOrder3TestTools::cleanOrder();
// Add voucher
$voucher1 = $tools->createVoucher('Voucher 10%', 10, 'percentageOff', false);
// Create cart manager instance
try {
    $cm = new rtShopCartManager();
} catch (Exception $e) {
    throw new sfException('Cart manager instance could not be created! Please check.');
}
// Add stocks to cart manager
$cm->addToCart($stock1, 2);
$cm->addToCart($stock2, 2);
// Add addresses to order
$tools->addAddressForOrder($cm->getOrder()->getId());
$tools->addAddressForOrder($cm->getOrder()->getId(), 'shipping');
// Loop through stocks in order
$t->comment('');
$t->comment('*****************************************************************************');
$stock_info = $cm->getOrder()->getStockInfoArray();
$i = 0;
$compare_charge = array(50, 30);