购物车里修改
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);
?>
修改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