/** * Create cart promotion and connect to product * * @param string $title * @param number $value * @param float $total_from * @param float $total_to * @param datetime $date_from * @param datetime $date_to * @param string $type * @param integer $count * @param boolean $stackable * @return integer */ public function createCartPromotion($title, $value = 10, $total_from = NULL, $total_to = NULL, $date_from = NULL, $date_to = NULL, $type = 'percentageOff', $count = 1, $stackable = true) { $promotion = new rtShopPromotionCart(); $promotion->setTitle($title); $promotion->setDateFrom($date_from); $promotion->setDateTo($date_to); $promotion->setTotalFrom($total_from); $promotion->setTotalTo($total_to); $promotion->setReductionType($type); $promotion->setReductionValue($value); $promotion->setCount($count); $promotion->setStackable($stackable); $promotion->save(); return $promotion->getId(); }
// Clean up $i3->delete(); $i4->delete(); unset($o1, $o2); $t->diag('***********************'); $t->diag('*** Promotion: Cart ***'); $t->diag('***********************'); // Add vouchers data try { rtShopPromotionTestTools::clean(); // Add 3 vouchers $i3 = new rtShopPromotionCart(); $i3->setTitle('Voucher'); $i3->setDateFrom(date('Y-m-d H:i:s', strtotime(sprintf("-%s months", 3)))); $i3->setDateTo(date('Y-m-d H:i:s', strtotime(sprintf("+%s months", 1)))); $i3->setTotalFrom(150); $i3->setTotalTo(250); $i3->setReductionType('dollarOff'); $i3->setReductionValue(10); $i3->setMode('Group'); $i3->setCount(100); $i3->save(); $i4 = new rtShopPromotionCart(); $i4->setTitle('Voucher'); $i4->setCode($code2); $i4->setDateFrom(date('Y-m-d H:i:s', strtotime(sprintf("-%s months", 3)))); $i4->setDateTo(date('Y-m-d H:i:s', strtotime(sprintf("+%s months", 1)))); $i4->setTotalTo(150); $i4->setReductionType('percentageOff'); $i4->setReductionValue(15); $i4->setMode('Single');