Add ability to set custom product option with negative price#14342
Add ability to set custom product option with negative price#14342mszydlo wants to merge 1 commit intomagento:2.2-developfrom
Conversation
Modify option value validator to accept negative prices that don't exceed product's special/regular price
|
|
|
Related PR: #13393 |
ihor-sviziev
left a comment
There was a problem hiding this comment.
I reviewed your changes, looks good, but in some parts it's not clear. Also unit tests are failing currently. Could you adjust them to be consistent with your changes + cover new cases?
| optionHandlers: {}, | ||
| optionTemplate: '<%= data.label %>' + | ||
| '<% if (data.finalPrice.value) { %>' + | ||
| '<% if (data.finalPrice.value > 0) { %>' + |
There was a problem hiding this comment.
I didn't get, why do we need this change?
| $title = $value['title'] ?? null; | ||
|
|
||
| if ($type === ProductPriceOptionsInterface::VALUE_PERCENT) { | ||
| $price += 100.0; |
There was a problem hiding this comment.
Could you describe why do we need to add +100 there?
| } | ||
|
|
||
| $customOption = $this->customOptionFactory->create(['data' => $customOptionData]); | ||
| $customOption->setProduct($product); |
There was a problem hiding this comment.
Why do we need this change?
| { | ||
| return $this->isInRange($option->getPriceType(), $this->priceTypes) && !$this->isNegative($option->getPrice()); | ||
| $productPrice = 0.0; | ||
| if ($option->getPriceType() === ProductPriceOptionsInterface::VALUE_PERCENT) { |
There was a problem hiding this comment.
Could you cover these changes with tests?
|
Hi @mszydlo thank you for this PR. I am currently doing a couple of things.
I will update you via this PR once I have some more information. Thank you for your patience. |
Description
Enabled ability to set negative prices for custom product options.
Fixed Issues
Manual testing scenarios