Backoffice - max cost margin #31
Reference in New Issue
Block a user
Delete Branch "backoffice-max-cost-margin"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
https://app.asana.com/0/697944902557002/838943199344918/f
SMOKE TEST :
Create three simple products
Create two bundles containing two simple product and one bundle that contains third simple product. Set margin (pricing tab) to 0
Bundles should be visible now in market and package status in products tab in back office should show "available"
Change margin in one bundle to value like 100
Change price of simple product to price that exceeds margin, like 5000
Bundle with margin different than zero should change status to "margin_exceeded" and it should not be visible in market. Other two bundles should keep their available status.
Now change margin to be greater than simple product price, like 10000
Bundle should be available again and visible in market.
Open bundle in market while status is available and keep that page open
Now change price of simple product or margin to make bundle invalid
Go back to opened package page / tab and try to add it to cart
There should be error and package should not be added
Reverse price again so bundle is available
Add it to cart but don't create order yet
Change price or margin so that bundle become invalid
Try to create order
There should be error and order should not be placed
Reverse price again so bundle is available
Try to create order
Order should be created without errors
added 1 commit
Compare with previous version
added 1 commit
Compare with previous version
This part with total cost is confusing to me. If bundle contains simple product + add on + option, total cost is calculated only for simple products. What if supplier increase price of option or/and add on ? Should package still be available or not, or just option/add on should not be available ?
added 18 commits
master57d61918- add minimum cost margin input boxaccc359c- handle bundle minimum cost margin read and updateea638707- use minimum cost margin in pricing panelac9c89e8- update name to reflect logic behind marginc7e8a526- add custom package statusafe4ac16- update package status on product update1e9f959b- fetch only available packages63c1ee94- prevent adding invalid package to cart8d2b1e52- prevent checkout with invalid packagebc74b504- fix const declaration4f31cc94- update package status on package update84ba574b- add detailed error messagee4a7b283- fix testsf3d911e5- remove debug logging4bdad78e- add testsCompare with previous version
This code does not take into into account relationships between packages and should only be used to get total prices for single package, since price margins are calculated on package level.
Do not handle this here. Separate into method that will be triggered on checkout validation hook and add notice error.
This action should not have its own separate file, the name is confusing and it is not clear on the first glance what is this for
and why do we have it.
Logic implemented is not related to product but package, and also logic implemented is specifically for
package pricing.
This action should be moved to Package_Pricing file since it applies package pricing logic.
Note: You cannot set taxonomy query like this, since there may be queries before yours. You query should
be added ass element to array, but first check if
$query['tax_query']is initialized.changed this line in version 5 of the diff
changed this line in version 5 of the diff
changed this line in version 5 of the diff
changed this line in version 5 of the diff
added 5 commits
8df4ec3d- move package validation to seperate function14eda981- add notice instead of throwing errorba2629ca- refactor9f3fe44b- add proper message when adding invalid package to cart55dc87e1- check if taxonomy query exists and append if existsCompare with previous version
This should not be here.
The idea is that calling of
WC()->checkout()->check_cart_items();will trigger actionwoocommerce_check_cart_itemsto which all validation functions should be hooked in to validate cart items.So check for existing error notices is handled below.
Why is this here?
This hook is not he one used for validation cart items. It is
woocommerce_check_cart_itemschanged this line in version 6 of the diff
changed this line in version 6 of the diff
changed this line in version 6 of the diff
added 1 commit
d7c34c3b- remove double code, change hook for validationCompare with previous version
added 1 commit
a5168d34- remove unnecessary codeCompare with previous version
merged
mentioned in commit
803e62ea69