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
9211f997
Commit
9211f997
authored
9 years ago
by
Reinhold Kainhofer
Browse files
Options
Downloads
Patches
Plain Diff
Finish evaluate_for_subcategories function
parent
46207f14
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_framework_joomla.php
+18
-7
18 additions, 7 deletions
rules_shipping_framework_joomla.php
with
18 additions
and
7 deletions
rules_shipping_framework_joomla.php
+
18
−
7
View file @
9211f997
...
...
@@ -336,6 +336,23 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework {
JPluginHelper
::
importPlugin
(
'vmshipmentrules'
);
JDispatcher
::
getInstance
()
->
trigger
(
'onVmShippingRulesGetCartValues'
,
array
(
&
$values
,
$cart
,
$products
,
$method
));
}
protected
function
getCategoryTreeRecursive
(
$catmodel
,
$parent_category_id
,
&
$categories
)
{
if
(
$catmodel
->
hasChildren
(
$parent_category_id
)){
// We need to call getCategories with vendorID=1, because the
// default "" will cause VM to check the current user for superuser
// access, which he usually does not have, and thus no child
// categories would be displayed.
$childCats
=
$catmodel
->
getCategories
(
/*$onlyPublished*/
false
,
$parent_category_id
,
/*child id*/
false
,
/*$keyword*/
""
,
/*VendorID*/
1
);
foreach
(
$childCats
as
$key
=>
$category
)
{
$categories
[]
=
$category
->
virtuemart_category_id
;
$this
->
getCategoryTreeRecursive
(
$catmodel
,
$category
->
virtuemart_category_id
,
$categories
);
}
}
}
/** Filter the given array of products and return only those that belong to the categories, manufacturers,
* vendors or products given in the $filter_conditions. The $filter_conditions is an array of the form:
...
...
@@ -352,15 +369,9 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework {
$catmodel
=
VmModel
::
getModel
(
'category'
);
foreach
(
$filter_conditions
[
'subcategories'
]
as
$catid
)
{
$subcategories
[]
=
$catid
;
// Get all child categories from the category model
$categories
=
$catmodel
->
getCategoryTree
(
$catid
,
0
,
/*onlyPublished=*/
false
);
foreach
(
$categories
as
$subcat
)
{
$subcategories
[]
=
$subcat
->
virtuemart_category_id
;
}
$categories
=
$this
->
getCategoryTreeRecursive
(
$catmodel
,
$catid
,
$subcategories
);
}
$subcategories
=
array_unique
(
$subcategories
);
JFactory
::
getApplication
()
->
enqueueMessage
(
"<pre>Subcategories: "
.
print_r
(
$subcategories
,
1
)
.
"</pre>"
,
'error'
);
}
...
...
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