• 欢迎访问开心洋葱网站,在线教程,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入开心洋葱 QQ群
  • 为方便开心洋葱网用户,开心洋葱官网已经开启复制功能!
  • 欢迎访问开心洋葱网站,手机也能访问哦~欢迎加入开心洋葱多维思维学习平台 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏开心洋葱吧~~~~~~~~~~~~~!
  • 由于近期流量激增,小站的ECS没能经的起亲们的访问,本站依然没有盈利,如果各位看如果觉着文字不错,还请看官给小站打个赏~~~~~~~~~~~~~!

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

实用教程 开心洋葱 1068次浏览 0个评论

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

 

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

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

下面是题的修改思路和大约的修改地方,自己只是为了以后能够在修改比较方便,就把这个笔记发布出来,为爱好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 ? '<br />' . $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 ? '<br />' . $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行增加

       

<?php
  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 '<br /> ' . $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网上商城的购物车产品价格及最后的结算价格
喜欢 (0)

您必须 登录 才能发表评论!

加载中……