Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
VirtueMart
Shipping by Rules for VirtueMart
Commits
d4cce0f1
Commit
d4cce0f1
authored
Dec 13, 2015
by
Reinhold Kainhofer
Browse files
AwoCoupon: First version of the AwoCoupon variables plugin
parent
237f155d
Changes
5
Hide whitespace changes
Inline
Side-by-side
plugins/awocoupon/awocoupon.php
View file @
d4cce0f1
...
...
@@ -6,7 +6,7 @@ defined ('_JEXEC') or die('Restricted access');
* AwoCoupon variables for VM Shipping by Rules
*
* @subpackage Plugins - VmShipmentRules
* @copyright Copyright (C) 201
4
Reinhold Kainhofer, office@open-tools.net
* @copyright Copyright (C) 201
5
Reinhold Kainhofer, office@open-tools.net
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
...
...
@@ -23,22 +23,53 @@ if (!class_exists ('VmPlugin')) {
/** Extension plugin for the "Shipping by Rules" shipping plugin for VirtueMart
*/
class
plgVmShipmentRules
Rules_
AwoCoupon
extends
VmPlugin
{
class
plgVmShipmentRulesAwoCoupon
extends
VmPlugin
{
/** Trigger to add variables to the cart values
* You can add new variables to the $cartvals array or modify existing ones. They will be directly
* available in all rules.
* Please notice that this function might also be called for only a subset of products of the cart.
*/
function
onVmShippingRulesGetCartValues
(
&
$cartvals
,
$cart
,
$products
,
$method
,
$cart_prices
)
{
// First, make sure coupons are processes (VM core processes third-party coupons AFTER the shipping)
// This does NOT update the cart_prices array, but at least it makes sure Awocoupon has processed the coupon
JPluginHelper
::
importPlugin
(
'vmcoupon'
);
if
(
!
empty
(
$cart
->
couponCode
))
{
$dispatcher
=
JDispatcher
::
getInstance
();
// TODO: This does not yet work...
// $returnValues = $dispatcher->trigger('plgVmCouponHandler', array($cart->couponCode, &$cart->cartData, $cart->cartPrices));
}
$coupon_discount
=
0
;
$session
=
JFactory
::
getSession
();
$coupon_row
=
$session
->
get
(
'coupon'
,
''
,
'awocoupon'
);
$cartvals
[
'awoproductdiscount'
]
=
0.0
;
$cartvals
[
'awoproductdiscountnotax'
]
=
0.0
;
// $cartvals['awoproductdiscounttax'] = 0.0;
$cartvals
[
'awoshippingdiscount'
]
=
0.0
;
$cartvals
[
'awoshippingdiscountnotax'
]
=
0.0
;
// $cartvals['awoshippingdiscounttax'] = 0.0;
$cartvals
[
'awodiscount'
]
=
0.0
;
if
(
!
empty
(
$coupon_row
))
{
$coupon_row
=
unserialize
(
$coupon_row
);
$coupon_discount
=
$coupon_row
[
'product_discount'
]
+
$coupon_row
[
'shipping_discount'
];
// JFactory::getApplication()->enqueueMessage("<pre>AwoCoupon row: ".print_r($coupon_row,1)."</pre>", 'error');
$cartvals
[
'awoproductdiscount'
]
=
$coupon_row
[
'product_discount'
];
$cartvals
[
'awoproductdiscountnotax'
]
=
$coupon_row
[
'product_discount_notax'
];
// $cartvals['awoproductdiscounttax'] = $coupon_row['product_discount_tax'];
$cartvals
[
'awoshippingdiscount'
]
=
$coupon_row
[
'shipping_discount'
];
$cartvals
[
'awoshippingdiscountnotax'
]
=
$coupon_row
[
'shipping_discount_notax'
];
// $cartvals['awoshippingdiscounttax'] = $coupon_row['shipping_discount_tax'];
$cartvals
[
'awodiscount'
]
=
$coupon_row
[
'product_discount'
]
+
$coupon_row
[
'shipping_discount'
];
}
$cartvals
[
'awodiscount'
]
=
$coupon_discount
;
}
$cartvals
[
'amountaftercoupon'
]
=
$cartvals
[
'amount'
]
-
$cartvals
[
'awoproductdiscount'
];
$cartvals
[
'amountwithtaxaftercoupon'
]
=
$cartvals
[
'amountaftercoupon'
];
$cartvals
[
'taxamountaftercoupon'
]
=
$cartvals
[
'taxamount'
]
-
(
$cartvals
[
'awoproductdiscount'
]
-
$cartvals
[
'awoproductdiscountnotax'
]);
$cartvals
[
'amountwithouttaxaftercoupon'
]
=
$cartvals
[
'amountaftercoupon'
]
-
$cartvals
[
'taxamountaftercoupon'
];
// TODO: Apply shipping coupon discounts
}
}
// No closing tag
plugins/awocoupon/language/en-GB/en-GB.plg_vmshipmentrules_
rules_
awocoupon.ini
→
plugins/awocoupon/language/en-GB/en-GB.plg_vmshipmentrules_awocoupon.ini
View file @
d4cce0f1
File moved
plugins/awocoupon/language/en-GB/en-GB.plg_vmshipmentrules_
rules_
awocoupon.sys.ini
→
plugins/awocoupon/language/en-GB/en-GB.plg_vmshipmentrules_awocoupon.sys.ini
View file @
d4cce0f1
File moved
plugins/awocoupon/plg_opentools_vmshipmentrules_awocoupon_v1.0.zip
deleted
100644 → 0
View file @
237f155d
File deleted
plugins/awocoupon/releases/plg_opentools_vmshipmentrules_awocoupon_v1.0.zip
0 → 100644
View file @
d4cce0f1
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment