Closed (fixed)
Project:
Commerce Shipping
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
23 Feb 2012 at 18:51 UTC
Updated:
13 Feb 2017 at 04:18 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
fagoComment #2
fagoFYI, I'm using this with a rule like the one attached.
Comment #3
googletorp commentedThanks for the patch fago, it looks good and I committed it.
Regarding the name of the Rule, I can understand why it's a bit confusing. I'm guessing Ryan named it this way because what the action actually does, is to add the shipping services to the order object. This is also how the rates are added as options. I'll try to see if we can find a way to make it more clear - thanks for the suggestions.
Comment #4
dready2011 commentedHey Fago,
this is exactly what i am looking for. But I cannot figure out yet how to use it.
What I've done so far:
1. Installed flat rate module. Created 2 flat rate shipping services:
- Free shipping for orders over the threshold of 40 Euro
- Standard Shipping for orders below the threshold with standard value of 3.8 Euro
2. I imported the rule you posted.
Now i'm not sure how to proceed. Do I have to change the actions of these flat rates servuces? I tried to change the actions from "Add a rate for a shipping service to an order" to "apply shipping rate to order". But the shipping service pane does still show up.
Could you describe the steps that have to made in order to automatically set the shipping rate and skip the shipping service pane? I am not really sure i understand what the rule does that you made.
Also: i would like to always show the shipping fee in the shopping cart block... any idea how to do this?
Thanks!
Comment #5
dready2011 commentedI figured it out, finally. I am new to the commerce module, and didn't realize that I had to disable the shipping step under admin/commerce/config/checkout.
After changing the shipping rule to react to the event 'After updating an existing commerce order' everything works as I wanted.
To add the shipping cost to the Cart-block, I removed a filter from the view.
Comment #6
lavisrap commentedThanks fago!
I was searching just for this functionality and it works fine in my shop: patch & rule.
Michael
Comment #8
felixSchl commentedThanks for sharing, works nicely!
Edit: I noticed that problems do remain if you step back from the final checkout page to make adjustments (let's say to the shipping address), it will not update the resulting shipping charge.
E.g. I have two zones, national and international, when I click back and switch from national to international, the national shipping fees still persist until I manually update the cart.
Comment #9
mrpeanut commentedI must be missing something. I applied the patch and imported the rule. The flat rate rule that comes with the module is disabled.
Auto-add shipping service rule reacts After updating an existing commerce order. Yet the flat rate doesn't get applied.
Do I have to keep the default flat rate rule, or change the rule provided in #2?
Comment #10
mrpeanut commentedAnd now I'm getting this error:
Fatal error: Cannot redeclare commerce_shipping_rate_apply() (previously declared in /home/sites/all/modules/commerce_shipping/commerce_shipping.rules.inc:214) in /home/sites/all/modules/commerce_shipping/commerce_shipping.rules.inc on line 275I'm assuming it's related. I haven't made any other changes.
[edit] Doh, didn't realize it was committed and I'm on dev. Replacing commerce_shipping.rules.inc fixed that error. Rule still isn't working, though.
Comment #11
googletorp commentedSo is working then?
Comment #12
mrpeanut commentedI think I'm trying to do something different. I'd like a delivery fee of $5 to be charged to every order and for that to show up in the cart. I got it to show in the cart from #5.
I disabled the included flat rate rule and changed the rule from #2 to react "After adding a product to the cart" and also "After updating an existing commerce order."
I also changed data comparison (commerce order status) from Checkout: Review to Shopping cart.
However, when adding a product to the cart, it still doesn't automatically add the delivery fee.
[edit] I just removed all the conditions from that rule and it now works. That may break something in the future, but for now, I'm all set. Thanks!
Comment #13
arun_ms commentedAm getting the following error,
when i import the above rule.
What should i do?
Comment #14
mrpeanut commented@arun_ms — Do you have Commerce Shipping and Commerce Flat Rate installed, plus a flat rate service set up?
Comment #15
arun_ms commented@MrPeanut - I installed Commerce Shipping and Commerce Shipping Flat Rate
I am newbie to drupal , i dont know about flat rate service set up.
When i tried to install Commerce Flat Rate it shows me error.
Thanks
Comment #16
mrpeanut commentedI believe that for this to work, you need to use Commerce Shipping (I'm using dev) and Commerce Flat Rate. If you're getting an error, post that in the issue queue for Commerce Flat Rate. The instructions are then on that module's project page for how to set up a flat rate service.
Comment #18
diwant commentedAwesome! Thanks all, this is so money.
I actually removed the check for if a current shipping thing exists because otherwise I was able to go and fill in a location with cheaper shipping, click 'Go Back' and change the location and not have the shipping update to the newer, correct, option. It seems to work fine even with my change.
Comment #19
Crouchie commentedHello dready2011,
how exactly did you add the shipping cost to the cart (#5)? In the Shopping cart form view is only this filter: (Position) Commerce Line Item: Line item is of a product line item type (true).
If I go forward to the review and then back to the cart, the shipping cost appears, but I only have one flat rate service, so it make sense to show it all the time in the cart.
kind regards,
Crouchie
Comment #20
nicolas bouteille commentedHi Crouchie,
A Commerce line item can concern products but also shipping services for example. The filter you are mentionning thus is exactly the one you need to disable. So that the line items displayed in the cart are not only products but also shipping informations...
Note that if you previously added a relation to the product like I did in order to display the product type, then you need NOT to Require this relationship. Indeed, this would act as well as a filter that would display only Commerce line items of type product...
Last, because you will probably need to have a different presentation for the products and the shipping line (no quantity field, no remove button, etc.) I would recommand to create a separate display and actually embed it just before the cart summary in the view footer. Haven't tested it yet however.
Comment #21
nicolas bouteille commentedOk finally, I found that the best way to show the shipping price in the cart form is to remove the "Cart summary" widget from the view footer and to replace it with the "Order Total" widget that nicely displays:
sub-total
shipping price
total
Comment #22
blacklabel_tom commentedHi All,
I've added an updated version of fargos rule that will always re-calculate the shipping on the checkout and review page.
In my use case the shipping changed based on the quantity and users were able to go back and add extra items without the shipping cost getting bumped up accordingly.
Cheers
Tom
Comment #23
rooby commentedWith the rules here I am still unable to get shipping to appear on the cart contents table when I first go to the checkout page.
It seems that the calculations happen after that pane has been rendered so I don't get the value until the next page load.
Adding the cart order status to the conditions also didn't seem to help.
Does anyone have a solution that would work for my use case?
Comment #24
rooby commentedAh the problem was the shipping address condition.
Since my shipping rates are not dependent on shipping I removed that and it works as I need it to.
Comment #25
maxplus commentedHi,
I'm also using the solution of Nicolas Bouteille from #21 in my checkout progress.
I'm showing a custom cart block in a sidebar during the checkout progress.
It is not perfect because I don't have a live-update of my cart block, but is is OK for now
Thanks
Comment #26
Frederic wbase commentedI've changed the rules so that it applies the first availabe shipping method. Also now it works together with discounts and coupons. See attachment.
Also don't fotget to disable the rule "Delete shipping methods on cart update" as described in https://www.drupal.org/node/1270112
Maybe it's time to close this issue?
Further more i think it would be a good idea to open a new issue with a general status update of this module and a module version witch has some patches applied so that we create a new dev faster?
Comment #27
roball commentedAttached is an updated rule code to be used for importing the rule "Auto-add shipping service".
It is based on #26, but has corrected the data selector of the actions to "commerce-order" (was "commerce_order"). It also removes "Shopping cart" from the commerce-order:status condition.
It should be noted that, unlike stated in #26, the rule "Delete shipping line items on shopping cart updates" (introduced by the "Commerce Shipping" module) must be kept active.
The rule "Collect rates: Flat rate" (introduced by the "Commerce Flat Rate" module) must be disabled. Instead, the imported rule "Auto-add shipping service" must be active.
Comment #28
Frederic wbase commented@roball: i don't know what your shipping method is, but if use your rule and enable the rule to delete shipping line items + disable the rule collect rates then it doesn't work anymore in combination with coupon codes or discounts that add free shipping... Als when you have multiple flat shipping services for multiple countries and you change your country during checkout the shipping costs aren't updated...
What version do you use of commerce shipping & flat rate?
Comment #29
roball commented@Frederic wbase, I am successfully using the latest releases of Shipping & Shipping UI (7.x-2.2) and Flat Rate (7.x-1.0-beta2), and thus are using only the Flat rate Shipping method. I have defined two Shipping services: Shipping of Book within EU and Shipping of Book outside EU. Only one of them can be applied, depending on the country the customer chooses from her Billing information customer profile. The correct shipping service is auto-added when the customer changes the country during checkout.
Comment #30
krembo commentedIf you use some conditions, say order total is less than 200, it doesn't work.
I tried to add this condition to Auto-add shipping service rule, but still no luck.
If shipping was added once it stays there no matter what.
Comment #31
Frederic wbase commented@robal thanks for the update. Do you also use coupons & discounts that apply free shipping?
Comment #32
sander wemagine commentedThe rule above did work, but if customer navigated from 'checkout review' to 'checkout' the shipping costs would sometimes change if your shop has multiple shipping services based on the order total.
This rule below based on #27:
Comment #33
guypaddock commentedI tried the rules proposed in this thread, but all were very fragile if we needed to support multiple shipping options, or needed to change parts of the order that might change the shipping amount.
Instead, we wrote this module:
https://www.drupal.org/project/commerce_shipping_on_review