forked from bagisto/bagisto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made Catalog Rules made compatible with new product types and updated…
… issue templates
- Loading branch information
1 parent
02f0d00
commit 23237f9
Showing
18 changed files
with
262 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,15 @@ name: "💡 Feature Request" | |
about: 'For ideas or feature requests, please make a pull request, or open an issue' | ||
--- | ||
|
||
This repository is only for reporting bugs or issues. If you need support, please use the forums: | ||
This repository is only for reporting bugs or issues. If you need support, please use | ||
other channels: | ||
|
||
- https://forums.bagisto.com/ | ||
1. Write an email - mailto:[email protected] | ||
|
||
2. Create support ticket on https://bagisto.uvdesk.com | ||
|
||
3. Visit forums to get support from our community (https://forums.bagisto.com) | ||
|
||
Alternatively, you may use Facebook (https://www.facebook.com/groups/bagisto/). | ||
|
||
We promise that more channels are coming soon!!! | ||
We promise that more channels are coming soon!!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,6 @@ about: 'This repository is only for reporting bugs or problems. If you need help | |
|
||
This repository is only for reporting bugs or issues. If you need support, please use: | ||
|
||
1. Write an email - mailto:[email protected] | ||
|
||
2. Create support ticket on https://bagisto.uvdesk.com | ||
|
||
3. Visit forums to get support from our community (https://forums.bagisto.com) | ||
1. Create support ticket on https://bagisto.uvdesk.com | ||
|
||
Thanks! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
**BUGS:** | ||
|
||
Please describe the issue that you solved if its not filed. Otherwise please mention issue #id and use comma | ||
if your PR is having multiple fixes. | ||
>Please describe the issue that you solved if its not filed. | ||
**Core development ideas or discussion:** | ||
>Otherwise please mention issue #id and use comma if your PR | ||
>solves multiple issues. | ||
Describe the feature in very short lines word usage limit is 200. Otherwise use **issue #id** if the issue was | ||
filed as **feature** request. | ||
**For things other than bugs:** | ||
|
||
**Which branch you should target?** | ||
|
||
You should fork the Bagisto repository and push your local changes to your own **development** branch. And after you are done then generate from your **development** branch to Bagisto's **master** branch. Use branches other than **master** if you are fixing any backward compatible issue. | ||
> Describe that thing in very short line, word limit is 200. | ||
> Otherwise use **issue #id** if the issue was filed as **feature** request. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?php | ||
|
||
namespace Webkul\Discount\Actions\Cart; | ||
|
||
abstract class Action | ||
{ | ||
/** | ||
* To hold the current rule | ||
*/ | ||
protected $rule; | ||
|
||
abstract public function calculate($rule); | ||
|
||
/** | ||
* Empty collection instance for keeping final list of items | ||
*/ | ||
protected $matchedItems; | ||
|
||
public function __construct() | ||
{ | ||
/** | ||
* Making $matchedItems property empty collection instance. | ||
*/ | ||
$this->matchedItems = collect(); | ||
} | ||
|
||
/** | ||
* To find the eligble items for the current rule, | ||
* | ||
* @param CartRule $rule | ||
* | ||
* @return Collection $matchedItems | ||
*/ | ||
public function getEligibleItems($rule) | ||
{ | ||
$cart = \Cart::getCart(); | ||
|
||
$items = $cart->items()->get(); | ||
|
||
$productIDs = $rule->product_ids; | ||
|
||
$productIDs = explode(',', $productIDs); | ||
|
||
$matchCriteria = $rule->uses_attribute_conditions ? $rule->product_ids : '*'; | ||
|
||
if ($matchCriteria == '*') { | ||
$this->matchedItems = $items; | ||
|
||
return $this->matchedItems; | ||
} else { | ||
$matchingIDs = explode(',', $matchCriteria); | ||
|
||
foreach ($items as $item) { | ||
foreach ($matchingIDs as $matchingID) { | ||
$childrens = collect(); | ||
$childrens = $item->children; | ||
|
||
foreach ($childrens as $children) { | ||
if ($children->product_id == $matchingID) { | ||
$this->pushItem($children); | ||
} | ||
} | ||
|
||
if ($item->product_id == $matchingID) { | ||
$this->pushItem($item); | ||
} | ||
} | ||
} | ||
|
||
return $this->matchedItems; | ||
} | ||
} | ||
|
||
/** | ||
* To check the items applicability | ||
*/ | ||
public function checkApplicability() | ||
{ | ||
$rule = $this->rule; | ||
|
||
$eligibleItems = $this->getEligibleItems($rule); | ||
|
||
$apply = function () use($rule, $eligibleItems) { | ||
if ($rule->action_type == 'percent_of_product') { | ||
return true; | ||
} else { | ||
if ($rule->action_type == 'whole_cart_to_percent' && $rule->uses_attribute_condition) { | ||
$matchIDs = explode(',', $rule->product_ids); | ||
|
||
foreach ($matchIDs as $matchID) { | ||
foreach ($eligibleItems as $item) { | ||
if (($item->child ? $item->child->product_id : $item->product_id) == $matchID) { | ||
return true; | ||
} | ||
} | ||
} | ||
|
||
return false; | ||
} else { | ||
return true; | ||
} | ||
} | ||
}; | ||
|
||
return $apply(); | ||
} | ||
|
||
|
||
private function pushItem($item) { | ||
$this->matchedItems->push($item); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.