Commit b8c331ab authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

V6.1: Attempt at per-cart-discounts...

parent d64dd383
......@@ -2,7 +2,7 @@ BASE=rules_shipping
BASE_ADV=rules_shipping_advanced
PLUGINTYPE=vmshipment
ZIPBASE=opentools_vm
VERSION=6.0
VERSION=6.1
PLUGINFILES=$(BASE).php $(BASE)_base.php $(BASE)_framework_joomla.php $(BASE).script.php $(BASE).xml index.html
PLUGINFILES_ADV=$(BASE_ADV).php $(BASE)_base.php $(BASE)_framework_joomla.php $(BASE_ADV).script.php $(BASE_ADV).xml index.html
......
<?xml version="1.0" encoding="UTF-8" ?>
<extension version="2.5" type="plugin" group="vmshipment" method="upgrade">
<name>OTSHIPMENT_RULES</name>
<creationDate>2014-09-14</creationDate>
<creationDate>2016-02-15</creationDate>
<author>Reinhold Kainhofer</author>
<authorUrl>http://www.open-tools.net</authorUrl>
<copyright>Copyright (C) 2013-2014, Reinhold Kainhofer</copyright>
<license>GPL v3+</license>
<version>6.0</version>
<version>6.1</version>
<description>OTSHIPMENT_RULES_DESC</description>
<files>
<filename plugin="rules_shipping">rules_shipping.php</filename>
......
<?xml version="1.0" encoding="UTF-8" ?>
<extension version="1.5" type="plugin" group="vmshipment" method="upgrade">
<name>OTSHIPMENT_RULES_ADV</name>
<creationDate>2014-09-14</creationDate>
<creationDate>2016-02-15</creationDate>
<author>Reinhold Kainhofer</author>
<authorUrl>http://www.open-tools.net</authorUrl>
<copyright>Copyright (C) 2013-2014, Reinhold Kainhofer</copyright>
<license>GPL v3+</license>
<version>6.0</version>
<version>6.1</version>
<description>OTSHIPMENT_RULES_ADV_DESC</description>
<files>
<filename plugin="rules_shipping_advanced">rules_shipping_advanced.php</filename>
......
......@@ -277,6 +277,7 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework {
}
protected function getOrderPrices ($cart, $products, /*$cart_prices, */$method) {
$cart_prices = $cart->cartPrices;
$data = array(
'amount' => 0,
'amountwithtax' => 0,
......@@ -289,43 +290,36 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework {
'salespricewithdiscount' => 0,
'discountamount' => 0,
'pricewithouttax' => 0,
// Bill-related prices: Will not be affected by scoping! Totals before and after cart-wide discounts.
'billtotal' => $cart_prices['billTotal'],
'billdiscountamount' => $cart_prices['billDiscountAmount'],
'billtaxamount' => $cart_prices['billTaxAmount'],
'billsubtotal' => $cart_prices['billSub'],
);
// if (!empty($cart_prices)) {
// // get prices for the whole cart -> simply user the cart_prices
// $data['amount'] = $cart_prices['salesPrice'];
// $data['amountwithtax'] = $cart_prices['salesPrice'];
// $data['amountwithouttax'] = $cart_prices['priceWithoutTax'];
// $data['baseprice'] = $cart_prices['basePrice'];
// $data['basepricewithtax'] = $cart_prices['basePriceWithTax'];
// $data['discountedpricewithouttax'] = $cart_prices['discountedPriceWithoutTax'];
// $data['salesprice'] = $cart_prices['salesPrice'];
// $data['taxamount'] = $cart_prices['taxAmount'];
// $data['salespricewithdiscount'] = $cart_prices['salesPriceWithDiscount'];
// $data['discountamount'] = $cart_prices['discountAmount'];
// $data['pricewithouttax'] = $cart_prices['priceWithoutTax'];
// } else {
// Calculate the prices from the individual products!
// Possible problems are discounts on the order total
foreach ($products as $product) {
// $prices = isset($product->allPrices)?($product->allPrices[$product->selectedPrice]):($product->prices);
$prices = $product->prices;
$quant = $product->quantity;
$data['amount'] += $quant * $prices['salesPrice'];
$data['amountwithtax'] += $quant * $prices['salesPrice'];
$data['amountwithouttax'] += $quant * $prices['priceWithoutTax'];
$data['baseprice'] += $quant * $prices['basePrice'];
$data['basepricewithtax'] += $quant * $prices['basePriceWithTax'];
$data['discountedpricewithouttax'] += $quant * $prices['discountedPriceWithoutTax'];
$data['salesprice'] += $quant * $prices['salesPrice'];
$data['taxamount'] += $quant * $prices['taxAmount'];
$data['salespricewithdiscount'] += $quant * $prices['salesPriceWithDiscount'];
$data['discountamount'] += $quant * $prices['discountAmount'];
$data['pricewithouttax'] += $quant * $prices['priceWithoutTax'];
// JFactory::getApplication()->enqueueMessage("<pre>getOrderPrices, cart=".print_r($cart,1)."</pre>", 'error');
// Calculate the prices from the individual products!
// Possible problems are discounts on the order total
foreach ($products as $product) {
// $prices = isset($product->allPrices)?($product->allPrices[$product->selectedPrice]):($product->prices);
$prices = $product->prices;
$quant = $product->quantity;
$data['amount'] += $quant * $prices['salesPrice'];
$data['amountwithtax'] += $quant * $prices['salesPrice'];
$data['amountwithouttax'] += $quant * $prices['priceWithoutTax'];
$data['baseprice'] += $quant * $prices['basePrice'];
$data['basepricewithtax'] += $quant * $prices['basePriceWithTax'];
$data['discountedpricewithouttax'] += $quant * $prices['discountedPriceWithoutTax'];
$data['salesprice'] += $quant * $prices['salesPrice'];
$data['taxamount'] += $quant * $prices['taxAmount'];
$data['salespricewithdiscount'] += $quant * $prices['salesPriceWithDiscount'];
$data['discountamount'] += $quant * $prices['discountAmount'];
$data['pricewithouttax'] += $quant * $prices['priceWithoutTax'];
// JFactory::getApplication()->enqueueMessage("<pre>prices: ".print_r($prices,1)."</pre>", 'error');
// JFactory::getApplication()->enqueueMessage("<pre>product: ".print_r($product,1)."</pre>", 'error');
}
// }
}
return $data;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment