Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Shipping by Rules for VirtueMart
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VirtueMart
Shipping by Rules for VirtueMart
Commits
589ef0f9
Commit
589ef0f9
authored
12 years ago
by
Reinhold Kainhofer
Browse files
Options
Downloads
Patches
Plain Diff
Whitespace fixes
parent
6b752e9c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
rules_shipping_base.php
+22
-22
22 additions, 22 deletions
rules_shipping_base.php
with
22 additions
and
22 deletions
rules_shipping_base.php
+
22
−
22
View file @
589ef0f9
...
...
@@ -25,12 +25,12 @@ if (!class_exists ('vmPSPlugin')) {
require
(
JPATH_VM_PLUGINS
.
DS
.
'vmpsplugin.php'
);
}
// Only declare the class once...
if
(
class_exists
(
'plgVmShipmentRules_Shipping_Base'
))
{
if
(
class_exists
(
'plgVmShipmentRules_Shipping_Base'
))
{
return
;
}
/** Shipping costs according to general rules.
* Supported Variables: Weight, ZIP, Amount, Products (1 for each product, even if multiple ordered), Articles
* Supported Variables: Weight, ZIP, Amount, Products (1 for each product, even if multiple ordered), Articles
* Assignable variables: Shipping, Name
*/
class
plgVmShipmentRules_Shipping_Base
extends
vmPSPlugin
{
...
...
@@ -408,21 +408,21 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin {
return
$dimensions
;
}
/** Allow child classes to add additional variables for the rules
/** Allow child classes to add additional variables for the rules
*/
protected
function
addCustomCartValues
(
VirtueMartCart
$cart
,
$cart_prices
,
&
$values
)
{
}
protected
function
getCartValues
(
VirtueMartCart
$cart
,
$method
,
$cart_prices
)
{
$address
=
((
$cart
->
ST
==
0
)
?
$cart
->
BT
:
$cart
->
ST
);
$zip
=
trim
(
$address
[
'zip'
]);
$cartvals
=
array
(
'zip'
=>
$zip
,
'zip1'
=>
substr
(
$zip
,
0
,
1
),
'zip2'
=>
substr
(
$zip
,
0
,
2
),
'zip3'
=>
substr
(
$zip
,
0
,
3
),
'zip4'
=>
substr
(
$zip
,
0
,
4
),
'zip5'
=>
substr
(
$zip
,
0
,
5
),
'zip6'
=>
substr
(
$zip
,
0
,
6
),
'articles'
=>
$this
->
getOrderArticles
(
$cart
),
$cartvals
=
array
(
'zip'
=>
$zip
,
'zip1'
=>
substr
(
$zip
,
0
,
1
),
'zip2'
=>
substr
(
$zip
,
0
,
2
),
'zip3'
=>
substr
(
$zip
,
0
,
3
),
'zip4'
=>
substr
(
$zip
,
0
,
4
),
'zip5'
=>
substr
(
$zip
,
0
,
5
),
'zip6'
=>
substr
(
$zip
,
0
,
6
),
'articles'
=>
$this
->
getOrderArticles
(
$cart
),
'products'
=>
$this
->
getOrderProducts
(
$cart
),
'amount'
=>
$cart_prices
[
'salesPrice'
],
'amountWithTax'
=>
$cart_prices
[
'salesPrice'
],
...
...
@@ -588,7 +588,7 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin {
}
if
(
class_exists
(
'ShippingRule'
))
{
if
(
class_exists
(
'ShippingRule'
))
{
return
;
}
...
...
@@ -667,7 +667,7 @@ class ShippingRule {
$res
=
false
;
switch
(
$terms
[
1
])
{
case
'<'
:
$res
=
(
$terms
[
0
]
<
$terms
[
2
]);
break
;
case
'<='
:
case
'<='
:
case
'=<'
:
$res
=
(
$terms
[
0
]
<=
$terms
[
2
]);
break
;
case
'=='
:
$res
=
(
$terms
[
0
]
==
$terms
[
2
]);
break
;
case
'!='
:
...
...
@@ -675,7 +675,7 @@ class ShippingRule {
case
'>='
:
case
'=>'
:
$res
=
(
$terms
[
0
]
>=
$terms
[
2
]);
break
;
case
'>'
:
$res
=
(
$terms
[
0
]
>
$terms
[
2
]);
break
;
case
'~'
:
case
'~'
:
$l
=
min
(
strlen
(
$terms
[
0
]),
strlen
(
$terms
[
2
]));
$res
=
(
strncmp
(
$terms
[
0
],
$terms
[
2
],
$l
)
==
0
);
break
;
...
...
@@ -692,7 +692,7 @@ class ShippingRule {
// We do not have the correct number of terms for chained comparisons, i.e. two terms leftover instead of one!
JFactory
::
getApplication
()
->
enqueueMessage
(
JText
::
sprintf
(
'VMSHIPMENT_RULES_EVALUATE_UNKNOWN_ERROR'
,
$this
->
rulestring
),
'error'
);
return
false
;
}
}
// All conditions were fulfilled, so we can return true
return
true
;
}
...
...
@@ -735,14 +735,14 @@ class ShippingRule {
case
' AND '
:
$res
=
true
;
foreach
(
$args
as
$a
)
{
$res
=
(
$res
&&
$a
);
};
break
;
case
'in'
:
$needle
=
array_shift
(
$args
);
$res
=
in_array
(
$needle
,
$args
);
break
;
case
'<'
:
case
'<='
:
case
'=<'
:
case
'=='
:
case
'<'
:
case
'<='
:
case
'=<'
:
case
'=='
:
case
'!='
:
case
'<>'
:
case
'<>'
:
case
'>='
:
case
'=>'
:
case
'=>'
:
case
'>'
:
case
'~'
:
$res
=
$this
->
evaluateComparison
(
array
(
$args
[
0
],
$op
,
$args
[
1
]),
$vals
);
break
;
...
...
@@ -774,7 +774,7 @@ class ShippingRule {
function
matches
(
$vals
)
{
// First, check the country, if any conditions are given:
if
(
count
(
$this
->
countries
)
>
0
&&
!
in_array
(
$vals
[
'country'
],
$this
->
countries
))
if
(
count
(
$this
->
countries
)
>
0
&&
!
in_array
(
$vals
[
'country'
],
$this
->
countries
))
return
False
;
foreach
(
$this
->
conditions
as
$c
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment