示例#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
function AddStandard()
{
    $cfg = new sc_configuration();
    $stdprod = $cfg->get("cart_fee_product");
    if ($stdprod != "") {
        $tmp = new products();
        $sp = $tmp->getproductByProdCode($stdprod);
        $cartProd = new CartProduct();
        $cartProd->option = "";
        $cartProd->prodcode = $stdprod;
        $cartProd->prodname = $sp->shorttext;
        $cartProd->unitprice = $sp->unitprice;
        $cartProd->quantity = 1;
        $cartProd->finalprice = $sp->unitprice;
        $cartProd->id = uniqid("S");
        $cart2 = new cart2();
        $cart2->removecartProduct($cartProd);
        $c = $cart2->readcart();
        if (count($c) > 0) {
            $cart2->addCartProduct($cartProd);
        }
    }
}