Example #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;
 }
Example #2
0
     $cart = $cart2->dumpCartXML();
     break;
 case "view_prod":
     $a = new product();
     $alist = $a->getPublishedProducts();
     display::view_prod($alist);
     break;
 case "checkout":
     $cart = new cart2();
     $cfg = new sc_configuration();
     $mintocheckout = $cfg->get("mincheckout");
     // check for minimum amount before checkout, default = 0 => any amount is enough
     if (!$mintocheckout) {
         $mintocheckout = 0;
     }
     $carttotal = $cart->getCartTotal();
     if ($carttotal < $mintocheckout) {
         $txt = JText::_('SC_LESS_THAN_MIN_AMOUNT', $mintocheckout);
         $mainframe->redirect("index.php?option=com_caddy&action=showcart&Itemid={$Itemid}", $txt);
     }
     $cart2 = new cart2();
     $cart = $cart2->readCart();
     $cfg = new sc_configuration();
     $pretextid = $cfg->get("pretextid");
     $posttextid = $cfg->get("posttextid");
     $db =& JFactory::getDBO();
     $query = "select * from #__content where id='{$pretextid}'";
     $db->setQuery($query);
     $pretext = $db->loadObject();
     $query = "select * from #__content where id='{$posttextid}'";
     $db->setQuery($query);