Closed (fixed)
Project:
Commerce Core
Version:
8.x-2.x-dev
Component:
Promotions
Priority:
Normal
Category:
Feature request
Assigned:
Issue tags:
Reporter:
Created:
20 Feb 2017 at 21:07 UTC
Updated:
27 Jun 2017 at 09:25 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
niko- commentedComment #3
niko- commentedComment #4
niko- commentedComment #5
joshmillerThis description appears to be inaccurate, maybe copy/pasted?
I think the object name "ProductEqual" is better ... I'd rather the label be "Product equals"
Again, it appears the description is a copy/paste hold over.
Shouldn't this be "Product variation field equals"? "Product field is" appears to be way too generic.
I would change the class name to "ProductVariationFieldEqual"
This should be a dependency injected call.
Formatting. Needs a space and a terminator.
Formatting. Needs a space and wrapped to 2 lines at the 80 character mark.
Summary could be more specific. Perhaps "Compares the product variation field type."
Copy/paste error.
"Product variation equals"?
Copy/Paste error.
Remove commented code.
Should be dependency injected.
Formatting.
Should be dependency injected.
Comment #6
mglamanWe also should have any product based promotions provided by the Product module, since we cannot guarantee it'll be enabled.
Comment #7
mglamanDiscussed with bojanz: one major change is the Product equals should allow you to select the product and default to All variations, then allowing specific variation choices. This simplifies UX and options by combining two conditions. If All variations is not selected let's limit by attributes to start (only Black is on sale, or only XXL)
EDIT: If the product variation type has no attributes, show a #multiple enabled select of all the titles. Or checkboxes.
Comment #8
mglamanMy work expanded quite a bit.
I need to update the order summary.
Comment #9
mglamanOkay, I went a little deep on this. Here's a patch to mark progress and concepts. I tried to simplify offer plugins to not need to specify target entity type. But I blew the scope.
Scope of this issue should stick to (for my own benefit)
This current patch attempted 1 and consolidate 4 & 5 into a single plugin, making it easier to provide shipping promotions. However, I should tackle that in a follow-up. Given that this issue will add a lot more test coverage, which also needs a huge bump.
Comment #10
mglamanComment #11
mglamanWe'll do product conditions in #2842924: Add a product condition and fixed off offers here.
Comment #12
mglamanComment #13
josephdpurcell commentedTaking a look at this now.
Comment #14
josephdpurcell commentedPer conversation with Matt, ignore previous history in this ticket.
The goal here is to create "fixed off" promotion, where you take an amount and subtract an amount. Look at modules/promotion/src/Plugin/Commerce/PromotionOffer/OrderPercentageOff.php as an example, it should be more or a less a copy-paste, rename, and refactor execute to subtract.
Ensure there are tests.
Comment #15
manojapare commentedAdded `Fixed offer` and test for the same.
Comment #16
niko- commentedHi @manojapare
You can't create adjustment
with amount more then order\order item total but in your implementation it is possible
Comment #17
niko- commentedComment #18
mglamanWe can just say "Amount" here, since it is a static/fixed amount off each time.
Offers no longer need to use `target_entity_type`.
Offers are always passed an order object, now. So getTargetEntity is only on conditions. Use
$this->getOrder()Technically nothing prevents promotions from doing this. I don't think it should be a concern of the offer plugin, but something Commerce itself guarantees. When calculating order total it never goes negative. Also, it might be a sign of improper promotion conditions not limiting your promotions.
Comment #19
niko- commented>Also, it might be a sign of improper promotion conditions not limiting your promotions.
But let's check the following:
we have $100 fixed discount for $90 order total
the code above will apply $100 ajustment with zero order total - thats ok until adjust total is hidden.
so order total will be the following
subtotal - $90
fixed discount - $100
total - $0.00
Isn't it ?
Comment #20
manojapare commented@niko @mglaman
Thanks for the guidance and help.
Had made the changes as per the review comments.
If fixed discount price is greater than order total price, I had made discount price same to order total price. So final total price won't be negative.
Doing like this will result in, say if order total price is 90 and fixed discount price is 100 then in order summary it will be displaying like:
subtotal - $90
discount - $90 // instead of $100
total - $0.00
Comment #21
josephdpurcell commentedNice work @manojapare.
It would seem I've wasted my time here--I didn't realize others were working on this. Nonetheless I'll contribute back the change of renaming "FixedOff" to "FixedAmountOff" if that is still desired.
Unassigning myself to indicate I'm not working on this.
Comment #22
imyaro commentedThanks for your work! This patch is - pretty helpful for me. But regarding the last fix - I have faced an issue:
Price constructor expects first param to be a numeric value, not the Price object.
Changed patch a little, see in the attachments
Comment #23
manojapare commented@zvse thanks. Patch is working fine. Marking as RTBC.
Comment #24
mglamanMust be a string.
No camel case
Wouldn't this just be
$order->getTotalPrice();Comment #25
mglamanComment #26
bojanz commentedTaking over.
Comment #28
bojanz commentedThe fixed amount needed to be a commerce_price form element.
But that caused me to run into #2885575: Switching plugins can crash if both share a configuration element of the same name, but not the same type, now fixed.
Committed, thanks everyone!
Comment #29
bojanz commentedClarifying title, since this issue didn't add a per-order-item offer.