php购物车修改单价,修改Zen Cart网上商城的购物车产品价格及最后的结算价格

修改Zen Cart网上商城的购物车产品价格及最后的结算价格

开发了个可以随商品免费赠送的插件,是根据Zen Cart 的better_together插件,修改而来,这里可以够买指定商品赠送某个商品,但客户要求在购物车时就显示产品的价格为零,也就是免费,这个样子的。

6157255ffa21937ee92e2fe1ef93c564.png

下面是题的修改思路和大约的修改地方,自己只是为了以后能够在修改比较方便,就把这个笔记发布出来,为爱好zencart的朋友们可以快速的修改zencart实现自己要的功能,话不多说了看下面的地方吧。

includes\modules\order_total\ot_better_together.php 类文件我已经根据自己的需求修改过

includes\modules\order_total 类文件我已经根据自己的需求修改过 具体的代码就全部贴出来了,大家可以根据自己的用处去修改。

zencart购物车里修改

includes\modules\pages\shopping_cart\header_php.php 第159行增加

include_once("./includes/modules/order_total/ot_better_together.php");

$free_products_class = new ot_better_together();

$free_products_array = $free_products_class->calculate_deductions_cart();

//print_r( $products[$i]['id'].'–');

//var_dump($cartShowTotal);

//print_r( $_SESSION['cart']->total.'–');

//print_r($free_products_array);

$products_free_price = $products[$i]['final_price'];

$products_quantity = $products[$i]['quantity'];

if($free_products_array[$products[$i]['id']]>0){

if($products[$i]['quantity']>1)

{

$products_quantity = $products_quantity-1;

}

else

{

$products_free_price = $products[$i]['final_price'] – $free_products_array[$products[$i]['id']] ;

}

$_SESSION['cart']->total -=  $free_products_array[$products[$i]['id']];

$_SESSION['cart']->free_better_together  +=  $free_products_array[$products[$i]['id']];

}

$cartShowTotal  = $currencies->format($_SESSION['cart']->total);

//var_dump($_SESSION['cart']);

unset($free_products_class);

并修改下面这行

$productsPrice = $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), $products_quantity) . ($products[$i]['onetime_charges'] != 0 ? '
' . $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');}

修改为:

$productsPrice = $currencies->display_price($products_free_price, zen_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . ($products[$i]['onetime_charges'] != 0 ? '
' . $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');}

这样修改后 购物车里的产品价格都可以修改并且小计(总价格)也会发生变化。

到下一步修改最后结账的地方和物流配送时

includes\templates\ladyidiy\templates\tpl_checkout_shipping_default.php 454行增加

include_once("./includes/modules/order_total/ot_better_together.php");

$free_products_class = new ot_better_together();

$free_products_array = $free_products_class->calculate_deductions_cart();

//print_r( $free_products_array);

//var_dump($cartShowTotal);

//print_r( $_SESSION['cart']->total.'–');

$products_free_price = $order->products[$i]['final_price'];

$products_quantity   = $order->products[$i]['qty'];

if($free_products_array[$order->products[$i]['id']]>0){

if($order->products[$i]['qty']>1)

{

$products_quantity = $products_quantity-1;

}

else

{

$products_free_price = $order->products[$i]['final_price'] – $free_products_array[$order->products[$i]['id']];

}

}

// var_dump($b);

unset($free_products_class);

?>

此行为修改的价格: <?php echo $currencies->display_price($products_free_price, $order->products[$i]['tax'], $products_quantity);

if ($order->products[$i]['onetime_charges'] != 0 ) echo '
' . $currencies->display_price($order->products[$i]['onetime_charges'], $order->products[$i]['tax'], 1);#p#分页标题#e#

?>

修改includes\modules\pages\checkout_shipping\header_php.php 第152行修改小计价格

$showTotal = $_SESSION['cart']->show_total();

改为  $showTotal = $_SESSION['cart']->show_total(); – $_SESSION['cart']->free_better_together;

最后把includes\classes\order_total.php 115行增加if($GLOBALS[$class]->code =='ot_better_together') continue;

去掉显示的Better Together Discount:  -US$108.00

这样把那个一起购买的插件代码修改后就可以正确的显示上面图片要的那种结果了。

开心洋葱 , 版权所有丨如未注明 , 均为原创丨未经授权请勿修改 , 转载请注明修改Zen Cart网上商城的购物车产品价格及最后的结算价格!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值