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
237f155d
Commit
237f155d
authored
Oct 25, 2015
by
Reinhold Kainhofer
Browse files
V5.7: Add variables MinQuantity and MaxQuantity
parent
f2c4bb07
Changes
6
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
237f155d
...
...
@@ -2,7 +2,7 @@ BASE=rules_shipping
BASE_ADV
=
rules_shipping_advanced
PLUGINTYPE
=
vmshipment
ZIPBASE
=
opentools_vm
VERSION
=
5.
6
VERSION
=
5.
7
PLUGINFILES
=
$(BASE)
.php
$(BASE)
_base.php
$(BASE)
.script.php
$(BASE)
.xml index.html
PLUGINFILES_ADV
=
$(BASE_ADV)
.php
$(BASE)
_base.php
$(BASE_ADV)
.script.php
$(BASE_ADV)
.xml index.html
...
...
images/plg_vmshipping_rules_shipping_plugins_icon.png
0 → 100644
View file @
237f155d
47.5 KB
releases/plg_opentools_vm_rules_shipping_advanced_v5.7.zip
0 → 100644
View file @
237f155d
File added
releases/plg_opentools_vm_rules_shipping_v5.7.zip
0 → 100644
View file @
237f155d
File added
rules_shipping.xml
View file @
237f155d
...
...
@@ -6,7 +6,7 @@
<authorUrl>
http://www.open-tools.net
</authorUrl>
<copyright>
Copyright (C) 2013-2014, Reinhold Kainhofer
</copyright>
<license>
GPL v3+
</license>
<version>
5.
6
</version>
<version>
5.
7
</version>
<description>
VMSHIPMENT_RULES_DESC
</description>
<files>
<filename
plugin=
"rules_shipping"
>
rules_shipping.php
</filename>
...
...
rules_shipping_base.php
View file @
237f155d
...
...
@@ -167,7 +167,7 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin {
}
// We need to call getCosts, because in J3 $method->rule_name and $method->cost as set in getCosts is no longer preserved.
// Instead, we simply call getCosts again, which as a side-effect sets all those members of $method.
$costs
=
$this
->
getCosts
(
$cart
,
$method
,
$cart
->
cartPrices
);
$costs
=
$this
->
getCosts
(
$cart
,
$method
,
isset
(
$cart
->
cartPrices
)
?
(
$cart
->
cartPrices
)
:
array
())
;
$values
[
'virtuemart_order_id'
]
=
$order
[
'details'
][
'BT'
]
->
virtuemart_order_id
;
$values
[
'order_number'
]
=
$order
[
'details'
][
'BT'
]
->
order_number
;
$values
[
'virtuemart_shipmentmethod_id'
]
=
$order
[
'details'
][
'BT'
]
->
virtuemart_shipmentmethod_id
;
...
...
@@ -175,8 +175,9 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin {
$values
[
'rule_name'
]
=
$method
->
rule_name
;
$weights
=
$this
->
getOrderWeights
(
$cart
,
$cart
->
products
,
$method
->
weight_unit
);
$values
[
'order_weight'
]
=
$weights
[
'weight'
];
$values
[
'order_articles'
]
=
$this
->
getOrderArticles
(
$cart
,
$cart
->
products
);
$values
[
'order_products'
]
=
$this
->
getOrderProducts
(
$cart
,
$cart
->
products
);
$counts
=
$this
->
getOrderCounts
(
$cart
,
$cart
->
products
);
$values
[
'order_articles'
]
=
$counts
[
'articles'
];
$values
[
'order_products'
]
=
$counts
[
'products'
];
$values
[
'shipment_weight_unit'
]
=
$method
->
weight_unit
;
$values
[
'shipment_cost'
]
=
$method
->
cost
;
$values
[
'tax_id'
]
=
$method
->
tax_id
;
...
...
@@ -593,16 +594,22 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin {
}
/** Functions to calculate all the different variables for the given cart and given (sub)set of products in the cart */
protected
function
getOrderArticles
(
VirtueMartCart
$cart
,
$products
)
{
$articles
=
0
;
protected
function
getOrderCounts
(
VirtueMartCart
$cart
,
$products
)
{
$counts
=
array
(
'articles'
=>
0
,
'products'
=>
count
(
$products
),
'minquantity'
=>
9999999999
,
'maxquantity'
=>
0
,
);
foreach
(
$products
as
$product
)
{
$articles
+=
$product
->
quantity
;
$counts
[
'articles'
]
+=
$product
->
quantity
;
$counts
[
'maxquantity'
]
=
max
(
$counts
[
'maxquantity'
],
$product
->
quantity
);
$counts
[
'minquantity'
]
=
min
(
$counts
[
'minquantity'
],
$product
->
quantity
);
}
return
$articles
;
}
protected
function
getOrderProducts
(
VirtueMartCart
$cart
,
$products
)
{
return
count
(
$products
);
$counts
[
'quantity'
]
=
$counts
[
'articles'
];
return
$counts
;
}
protected
function
getOrderDimensions
(
VirtueMartCart
$cart
,
$products
,
$length_dimension
)
{
...
...
@@ -808,10 +815,7 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin {
public
function
getCartValues
(
VirtueMartCart
$cart
,
$products
,
$method
,
$cart_prices
)
{
$address
=
((
$cart
->
ST
==
0
||
$cart
->
STsameAsBT
==
1
)
?
$cart
->
BT
:
$cart
->
ST
);
$cartvals
=
array_merge
(
array
(
'articles'
=>
$this
->
getOrderArticles
(
$cart
,
$products
),
'products'
=>
$this
->
getOrderProducts
(
$cart
,
$products
),
),
$this
->
getOrderCounts
(
$cart
,
$products
),
// Add the prices, optionally calculated from the products subset of the cart
$this
->
getOrderPrices
(
$cart
,
$products
,
$cart_prices
),
// Add 'skus', 'categories', 'vendors' variables:
...
...
Write
Preview
Supports
Markdown
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