$stock7tovar2->save(); } catch (Exception $e) { throw new sfException('Stocks could not be added to variations! Please check.'); } // Set taxes and shipping rate sfConfig::set('app_rt_shop_tax_rate', 10); sfConfig::set('app_rt_shop_tax_mode', 'inclusive'); 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);
/** * Check if stock exists, and redirect back to product if there are any issues. * * @param rtShopStock $rt_shop_stock */ private function checkIfStockIsAvailable(rtShopStock $rt_shop_stock) { if (!$rt_shop_stock) { $this->getUser()->setFlash('error', 'We don\'t seem to have any stock available for that selection.'); $this->redirect('rt_shop_product_show', $rt_shop_stock->getRtShopProduct()); } }