Tags/topics: 
3
Answers
Vote up!
0
Vote down!

Drupal Commerce - set Shipping costs

Hello I have activated Drupal7 Commerce using http://drupal.org/project/commerce_kickstart

I need to calculate the shipping costs according to the following rules:

* For purchases up to € 50 shipping cost € 6.50.
* For purchases over € 50 and up to € 70, shipping cost € 3.50
* For purchases over € 70, FREE shipping.

With Ubercart I found the solution by using the "Conditional Actions"

With Commerce I am a bit in trouble.
First I created in admin/commerce/config/ 3 flat rate shipping service:

Total purchases of up to € 50
Total purchases from € 50 to € 70
Total purchases over € 70
By setting the various base rate (6.5, 3.5, 0)

My difficulty arises in creating the correct conditions because these rules are applied.
1) I go to admin / commerce / config / shipping and I for example click on Configure component related to "Total purchases of up to € 50"
2) in Conditions, do I select Add condition and Total product quantity comparison
imposed in date selector site: current-cart-order: commerce-order-total:
in Value < Quantity 50

but I get the error "Data selector site:current-cart-order:commerce-order-total: for parameter commerce_order is invalid."

I don't understand how to set if the total purchase is < 50 rule applies "Total purchases of up to € 50"

Once you understand that I can set up various rules

thanks

Janhu
Asked by: Janhu
on October 19, 2012

3 Answers

Vote up!
1
Vote down!

[SOLVED]
I remove any shipping service and I restart from the beginning.

I define 3 services:

1) flat rate service "For purchases up to € 50"
base rate 6.50 EUR

Condition
Data comparison
Selected data: commerce-order:commerce-order-total:amount
The comparison operator. is lower then
Data value: 5000

Actinon
i leave
Add a rate for a shipping service to an order

2) flat rate service "Total purchases over € 50 and up to € 70"
base rate 3.50 EUR

Condition
Data comparison
Selected data: commerce-order:commerce-order-total:amount
The comparison operator. is greater than
Data value: 4999
AND
Selected data: commerce-order:commerce-order-total:amount
The comparison operator. is lower then
Data value: 7000

Actinon
i leave
Add a rate for a shipping service to an order

3) flat rate service "Total purchases over € 70"
base rate 0 EUR

Condition
Data comparison
Selected data: commerce-order:commerce-order-total:amount
The comparison operator. is greater than
Data value: 6999

Actinon
i leave
Add a rate for a shipping service to an order

Now i working well
Thanks

Janhu
Answer by: Janhu
Posted: Oct 24, 2012
Vote up!
0
Vote down!

Hi Scorpio26,

You will need a data comparison rather than a total product quantity comparison.

In your step two, add a condition 'data comparison'

Data to select is commerce-order:commerce-order-total:amount and in the next step of setting up the condition you will be able to select greater than or less than as the case may be.

In the Data Value field you need to change to direct input and enter the amount in raw unit format (ie. enter 1000 for 10 dollars) then save your condition and go see if it all works.

Remember to turn on rules debugging so that you can get a little bit more info when you are setting up your rules.

B

Answer by: BernieCram
Posted: Oct 24, 2012
Vote up!
-1
Vote down!

BernieCram Thanks for the reply
My new scenario now is as follows:

shipping services: Total purchases of up to € 50

date comparison
Selected date: commerce-order: commerce-order-total: amount-float
The comparison operator: is lower than
The value to compare with the data. Value: 50

or

{ "commerce_shipping_service_total_purchases_up_to_50" : {
    "LABEL" : "Total purchases of up to € 50",
    "PLUGIN" : "rule",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "commerce_order" : { "label" : "Order", "type" : "commerce_order" } },
    "IF" : [
      { "data_is" : {
          "data" : [ "commerce-order:commerce-order-total:amount-float" ],
          "op" : "\u003C",
          "value" : "50"
        }
      }
    ],
    "DO" : [  ]
  }
}

At the Shipping step I have the error:

"The shipping pane is empty because a shipping method hasn't been enabled. Another option is to remove the pane completely by dragging the "Shipping" pane to the "Disable" section of the checkout process."

    0 ms Reacting on event Collecting shipping rates for an order.
    0.237 ms Evaluating conditions of rule Collect rates: Flat rate. [edit]
    0.25 ms AND evaluated to TRUE.
        0 ms Rule Collect rates: Flat rate fires.
        0.227 ms Evaluating the action commerce_shipping_method_collect_rates. [edit]
            0 ms Executing rule Rate Total purchases of up to € 50.
            0.173 ms Evaluating conditions of rule Rate Total purchases of up to € 50. [edit]
            1.908 ms The condition data_is evaluated to TRUE [edit]
            1.92 ms AND evaluated to TRUE.
                0 ms Rule Rate Total purchases of up to € 50 fires.
                0.02 ms Rule Rate Total purchases of up to € 50 has fired.
            2.021 ms Finished executing of rule Rate Total purchases of up to € 50.
        3.395 ms Rule Collect rates: Flat rate has fired.
    3.697 ms Evaluating conditions of rule Costi di spedizione con Total purchases of up to € 50. [edit]
    3.708 ms AND evaluated to TRUE.
        0 ms Rule Costi di spedizione con Total purchases of up to € 50 fires.
        0.024 ms Rule Costi di spedizione con Total purchases of up to € 50 has fired.
    3.768 ms Finished reacting on event Collecting shipping rates for an order.
Janhu
Answer by: Janhu
Posted: Oct 24, 2012