Skip to content
Snippets Groups Projects
Commit b8c331ab authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

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

parent d64dd383
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ BASE=rules_shipping ...@@ -2,7 +2,7 @@ BASE=rules_shipping
BASE_ADV=rules_shipping_advanced BASE_ADV=rules_shipping_advanced
PLUGINTYPE=vmshipment PLUGINTYPE=vmshipment
ZIPBASE=opentools_vm 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=$(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 PLUGINFILES_ADV=$(BASE_ADV).php $(BASE)_base.php $(BASE)_framework_joomla.php $(BASE_ADV).script.php $(BASE_ADV).xml index.html
......
File added
File added
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<extension version="2.5" type="plugin" group="vmshipment" method="upgrade"> <extension version="2.5" type="plugin" group="vmshipment" method="upgrade">
<name>OTSHIPMENT_RULES</name> <name>OTSHIPMENT_RULES</name>
<creationDate>2014-09-14</creationDate> <creationDate>2016-02-15</creationDate>
<author>Reinhold Kainhofer</author> <author>Reinhold Kainhofer</author>
<authorUrl>http://www.open-tools.net</authorUrl> <authorUrl>http://www.open-tools.net</authorUrl>
<copyright>Copyright (C) 2013-2014, Reinhold Kainhofer</copyright> <copyright>Copyright (C) 2013-2014, Reinhold Kainhofer</copyright>
<license>GPL v3+</license> <license>GPL v3+</license>
<version>6.0</version> <version>6.1</version>
<description>OTSHIPMENT_RULES_DESC</description> <description>OTSHIPMENT_RULES_DESC</description>
<files> <files>
<filename plugin="rules_shipping">rules_shipping.php</filename> <filename plugin="rules_shipping">rules_shipping.php</filename>
......
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<extension version="1.5" type="plugin" group="vmshipment" method="upgrade"> <extension version="1.5" type="plugin" group="vmshipment" method="upgrade">
<name>OTSHIPMENT_RULES_ADV</name> <name>OTSHIPMENT_RULES_ADV</name>
<creationDate>2014-09-14</creationDate> <creationDate>2016-02-15</creationDate>
<author>Reinhold Kainhofer</author> <author>Reinhold Kainhofer</author>
<authorUrl>http://www.open-tools.net</authorUrl> <authorUrl>http://www.open-tools.net</authorUrl>
<copyright>Copyright (C) 2013-2014, Reinhold Kainhofer</copyright> <copyright>Copyright (C) 2013-2014, Reinhold Kainhofer</copyright>
<license>GPL v3+</license> <license>GPL v3+</license>
<version>6.0</version> <version>6.1</version>
<description>OTSHIPMENT_RULES_ADV_DESC</description> <description>OTSHIPMENT_RULES_ADV_DESC</description>
<files> <files>
<filename plugin="rules_shipping_advanced">rules_shipping_advanced.php</filename> <filename plugin="rules_shipping_advanced">rules_shipping_advanced.php</filename>
......
...@@ -277,6 +277,7 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework { ...@@ -277,6 +277,7 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework {
} }
protected function getOrderPrices ($cart, $products, /*$cart_prices, */$method) { protected function getOrderPrices ($cart, $products, /*$cart_prices, */$method) {
$cart_prices = $cart->cartPrices;
$data = array( $data = array(
'amount' => 0, 'amount' => 0,
'amountwithtax' => 0, 'amountwithtax' => 0,
...@@ -289,43 +290,36 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework { ...@@ -289,43 +290,36 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework {
'salespricewithdiscount' => 0, 'salespricewithdiscount' => 0,
'discountamount' => 0, 'discountamount' => 0,
'pricewithouttax' => 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)) { // JFactory::getApplication()->enqueueMessage("<pre>getOrderPrices, cart=".print_r($cart,1)."</pre>", 'error');
// // get prices for the whole cart -> simply user the cart_prices
// $data['amount'] = $cart_prices['salesPrice'];
// $data['amountwithtax'] = $cart_prices['salesPrice']; // Calculate the prices from the individual products!
// $data['amountwithouttax'] = $cart_prices['priceWithoutTax']; // Possible problems are discounts on the order total
// $data['baseprice'] = $cart_prices['basePrice']; foreach ($products as $product) {
// $data['basepricewithtax'] = $cart_prices['basePriceWithTax']; // $prices = isset($product->allPrices)?($product->allPrices[$product->selectedPrice]):($product->prices);
// $data['discountedpricewithouttax'] = $cart_prices['discountedPriceWithoutTax']; $prices = $product->prices;
// $data['salesprice'] = $cart_prices['salesPrice']; $quant = $product->quantity;
// $data['taxamount'] = $cart_prices['taxAmount']; $data['amount'] += $quant * $prices['salesPrice'];
// $data['salespricewithdiscount'] = $cart_prices['salesPriceWithDiscount']; $data['amountwithtax'] += $quant * $prices['salesPrice'];
// $data['discountamount'] = $cart_prices['discountAmount']; $data['amountwithouttax'] += $quant * $prices['priceWithoutTax'];
// $data['pricewithouttax'] = $cart_prices['priceWithoutTax']; $data['baseprice'] += $quant * $prices['basePrice'];
// } else { $data['basepricewithtax'] += $quant * $prices['basePriceWithTax'];
// Calculate the prices from the individual products! $data['discountedpricewithouttax'] += $quant * $prices['discountedPriceWithoutTax'];
// Possible problems are discounts on the order total $data['salesprice'] += $quant * $prices['salesPrice'];
foreach ($products as $product) { $data['taxamount'] += $quant * $prices['taxAmount'];
// $prices = isset($product->allPrices)?($product->allPrices[$product->selectedPrice]):($product->prices); $data['salespricewithdiscount'] += $quant * $prices['salesPriceWithDiscount'];
$prices = $product->prices; $data['discountamount'] += $quant * $prices['discountAmount'];
$quant = $product->quantity; $data['pricewithouttax'] += $quant * $prices['priceWithoutTax'];
$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>prices: ".print_r($prices,1)."</pre>", 'error');
// JFactory::getApplication()->enqueueMessage("<pre>product: ".print_r($product,1)."</pre>", 'error'); // JFactory::getApplication()->enqueueMessage("<pre>product: ".print_r($product,1)."</pre>", 'error');
}
}
// }
return $data; return $data;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment