Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
when I create a percentage promotion on shipping costs are not fixed rate, the calculation is not correct.
Catching EXPE0 I posted the price without discount.
Catching EXPE1 you see the configuration for a discount on a fixed rate.
Catching EXPE2 reducing operates on a fixed rate.
Catching EXPE3 you see the configuration for a discount on the price depending on weight.
Catching EXPE4 reduction is not correct.
thank you in advance for your help.
Comment | File | Size | Author |
---|---|---|---|
#33 | commerce_discount-shipping_rules_issue-2699345-33.patch | 15.54 KB | simeon157 |
| |||
#31 | interdiff-2699345-22-26.txt | 2.83 KB | simeon157 |
#26 | commerce_discount-shipping_rules_issue-2699345-26.patch | 15.54 KB | simeon157 |
#24 | commerce_discount-shipping_rules_issue-2699345-24.patch | 16.59 KB | simeon157 |
#22 | shipping-discount-2699345-22.patch | 13.8 KB | potop |
|
Comments
Comment #2
potop CreditAttribution: potop commentedI have the same issue. In our configuration we have 4 different shipping methods and commerce_discount_commerce_shipping_method_collect_rates($method, $order) is being called for every of these methods. And we have shipping price discounted 4 times in a row. So if we set 50% discount we get 93.75% discount (1-0.5^4).
So we probably need to add parameter $method_name to "commerce_discount_percent_off_shipping" event and check it when deciding if we need to apply discount to the shipping rate of the order.
Comment #3
rszrama CreditAttribution: rszrama at Centarro commentedDoes this title more accurately reflect the issue?
Comment #4
potop CreditAttribution: potop commentedYes!
Comment #5
rszrama CreditAttribution: rszrama at Centarro commentedOk, cool - will try to reproduce and resolve this ASAP.
Comment #6
potop CreditAttribution: potop commentedAdded test for this case.
Unfortunately couldn't find any tests for shipping neither in Discount module nor in Shipping module.
So this test is a first of a kind and needs review anyway (for example we can assert directly shipping_rate's prices but it would look more synthetic)
Comment #7
joelpittetSetting the status to "needs review" see what the testbot will say. Thanks for writing tests @potop
Comment #9
joelpittetJust a quick review and it looks like it may not have been created against the right branch.
This looks like an accidental change?
This should be probably done in your new commerce_discount_shipping.test
Comment #10
joelpittetLet's see if this works.
Comment #12
potop CreditAttribution: potop commentedYes. You are right.
Commerce Shipping module should be enabled before Discount module otherwise no shipping-related offers are initialized and cannot be tested. So we need to modify CommerceDiscountTestBase::setUp() to be able to do it.
I just made it the easiest way without adding a parameter to pass more modules to it. And as Discount has so many offers related to Shipping it just seemed ok to me.
This test is supposed to fail now as the reported issue exists, but without exception. The only its' assertion should fail.
Comment #13
joelpittetAh interesting, well let's make that more possible, and I made a typo and enabled commerce_discount twice with a bad copy/paste.
Comment #15
joelpittetI made a mistake on the last posting with my array_merge(). But where does 'commerce_shipping_dummy' come from? There is an example one maybe it should have been 'commerce_shipping_example'?
Comment #16
joelpittetRunning the code locally seems to confirm example is correct, but I could be wrong still, LMK.
This passes locally, the assertion didn't fail. Maybe there is something else in the scenario that causes this to fail. Always good to have more tests though, feel free to iterate.
Comment #18
joelpittetAnd of course I post the wrong files.
Comment #19
potop CreditAttribution: potop commentedShipping Example contains only one shipping method while we need two to reproduce the issue so another module was added for testing purposes only.
And I managed to miss it in my patch.
Comment #21
potop CreditAttribution: potop commentedNow it seems to fail as expected!
Comment #22
potop CreditAttribution: potop commentedThis new patch contains fix to the issue so tests should pass this time.
The fix also needs review.
It contains following changes:
Comment #23
potop CreditAttribution: potop commentedComment #24
simeon157 CreditAttribution: simeon157 commentedPatch #22 works for the case where you do not select a shipping service. In the case that we have a shipping service selected in the discount, that shipping service gets discounted by the rule multiple times. I've added a check to prevent this. Please review.
Comment #26
simeon157 CreditAttribution: simeon157 commentedIt seems I've used a wrong patch as my base for the patch in the previous commit. This should hopefully work now.
Comment #27
simeon157 CreditAttribution: simeon157 commentedComment #29
simeon157 CreditAttribution: simeon157 commentedComment #30
joelpittetCould you create an interdiff with your changes and try again with the patch?
https://www.drupal.org/documentation/git/interdiff
Comment #31
simeon157 CreditAttribution: simeon157 commentedThis is the interdiff, between the patch from #22 and #26, it adds a check if the shipping service exists, to prevent any fatal errors.
Comment #32
simeon157 CreditAttribution: simeon157 commentedComment #33
simeon157 CreditAttribution: simeon157 commentedSorry for the late reply. Re-uploading the patch. No idea what happened with the last one.
Comment #34
jsacksick CreditAttribution: jsacksick at Centarro commented@simeon157: Important changes related to free shipping & % off shipping will soon be committed to the codebase.
Could you confirm the bug still occurs with the patch from #2910160: Fix the "free shipping" offer type? This patch is supposed to fix various issues related to free shipping.