예제 #1
0
 function redeemvoucher($voucher)
 {
     global $mainframe;
     $cfg = new sc_configuration();
     $cfp = $cfg->get("taxrate");
     $cfp = str_replace("%", "", $cfp);
     if ($cfp > 1) {
         $cfp = $cfp / 100;
     }
     $taxrate = $cfp;
     $cartProd = new CartProduct();
     $cartProd->prodcode = "voucher";
     $cartProd->option = "";
     $cartProd->prodname = $voucher->name;
     $cartProd->unitprice = 0;
     $cartProd->quantity = 1;
     $cartProd->finalprice = 0;
     // matheval("$cartProd->unitprice $cartProd->formula");
     $cart = new cart2();
     $cart->removeCartProduct($cartProd);
     // remove any vouchers from the cart
     /**
     		$acart=$cart->readCart(); // returns array of cart products
     		$gtotal=0;
     		foreach ($acart as $key=>$cartproduct) {
     			$total=$cartproduct->quantity*$cartproduct->finalprice;
     			$gtotal= $gtotal + $total;
     		}
     */
     $gtotal = $cart->getCartTotal();
     $korting = $gtotal - matheval("{$gtotal} {$voucher->formula}");
     $cartProd->finalprice = $korting * -1;
     // just to get the amount back in the cart
     $cartProd->unitprice = $cartProd->finalprice;
     $cartProd->id = "voucher";
     $cart->addCartProduct($cartProd);
     // now return the values for immediate display
     $gtotal = $korting;
     $tax = $gtotal * $taxrate;
     $res['korting'] = $korting;
     $res['subtotal'] = $gtotal;
     $res['tax'] = $tax;
     $res['carttotal'] = $gtotal + $tax;
     return $res;
 }
예제 #2
0
파일: caddy.php 프로젝트: bizanto/Hooked
         $mainframe->redirect(urldecode($lasturl));
     } else {
         $mainframe->redirect("index.php?option=com_caddy&action=showcart&Itemid={$Itemid}");
     }
     break;
 case "changeqty":
     $product = new products();
     $p = $product->getproductByProdCode($cartProd->prodcode);
     $cartProd = new CartProduct();
     $cartProd->id = JRequest::getVar('id');
     $cartProd->prodcode = JRequest::getVar('edtprodcode');
     $cartProd->quantity = abs(JRequest::getInt('edtqty'));
     // restrict to positive integer values
     $cartProd->unitprice = $p->unitprice;
     // retrieve price from DB not from session vars
     $cartProd->finalprice = matheval("{$cartProd->unitprice} {$cartProd->formula}");
     $cfg = new sc_configuration();
     if ($cfg->get("checkoos") == 1) {
         // check for available quantity before making the change in the cart
         $product = new products();
         $p = $product->getproductByProdCode($cartProd->prodcode);
         if ($p->av_qty < $cartProd->quantity) {
             $lasturl = "index.php?option=com_caddy&action=showcart&Itemid={$Itemid}";
             $mainframe->redirect($lasturl, JText::_("SC_MINQTY_WARNING"));
         }
     }
     $cart2 = new cart2();
     $cart2->setCartProductQty($cartProd);
     $c = $cart2->getCartNumbers();
     if ($c == 1 and $cart2->isInCart("voucher")) {
         $mainframe->redirect("index.php?option=com_caddy&action=emptycart&Itemid={$Itemid}");