Hi! I'm testing commerce flat rate (7.x-1.0-beta1) and commerce shipping (7.x-2.0-beta1).
I'm trying to set two services:

  • free shipping for orders greater than 400 EUR
  • fixed rate for orders not greater than 400 EUR

I've choose to negate the "greater than" because there isn't an operator "less than or equal". If you use greater than 400 and less than 400, an order of exactly 400 will never be matched.

On the "shipping methods tabs" the reaction rule "Collect rates: Flat rate" is:

{ "commerce_shipping_method_flat_rate" : {
    "LABEL" : "Collect rates: Flat rate",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "commerce_shipping" ],
    "ON" : [ "commerce_shipping_collect_rates" ],
    "DO" : [
      { "commerce_shipping_method_collect_rates" : {
          "shipping_method_name" : "flat_rate",
          "commerce_order" : [ "commerce-order" ]
        }
      }
    ]
  }
}

I've added two "flat rate service" and the two component rules are:

Free shipping on order greater than 400EUR:

{ "commerce_shipping_service_spedizione_gratuita" : {
    "LABEL" : "Rate Spedizione gratuita",
    "PLUGIN" : "rule",
    "REQUIRES" : [ "rules", "commerce_shipping" ],
    "USES VARIABLES" : { "commerce_order" : { "type" : "commerce_order", "label" : "Order" } },
    "IF" : [
      { "data_is" : {
          "data" : [ "commerce-order:commerce-order-total:amount" ],
          "op" : "\u003e",
          "value" : "400"
        }
      }
    ],
    "DO" : [
      { "commerce_shipping_service_rate_order" : {
          "shipping_service_name" : "spedizione_gratuita",
          "commerce_order" : [ "commerce-order" ]
        }
      }
    ]
  }
}

Fixed rate on order not greater than 400EUR:

{ "commerce_shipping_service_spedizione_fissa" : {
    "LABEL" : "Rate Spedizione fissa",
    "PLUGIN" : "rule",
    "REQUIRES" : [ "rules", "commerce_shipping" ],
    "USES VARIABLES" : { "commerce_order" : { "label" : "Order", "type" : "commerce_order" } },
    "IF" : [
      { "NOT data_is" : {
          "data" : [ "commerce-order:commerce-order-total:amount" ],
          "op" : "\u003e",
          "value" : "400"
        }
      }
    ],
    "DO" : [
      { "commerce_shipping_service_rate_order" : {
          "shipping_service_name" : "spedizione_fissa",
          "commerce_order" : [ "commerce-order" ]
        }
      }
    ]
  }
}

On the checkout / shipping page there is always the free shipping. I've tried with a total cart amount less than 400, equals and greater. The only service available is always the free shipping one, in every case.

If I delete the "free shipping" service the "fixed rate" one is also not shown.

Please ask if I can provide further information in order to solve this issue.

Thanks.

Comments

I've added an action on the reaction rule "Collect rates: Flat rate" which prints a message with [commerce-order:commerce-order-total:amount]. I've discovered that the total amount is multiplied by 100! Now I'm investigating :-)

The token commerce-order:commerce-order-total:amount doesn't use commerce_currency_format(). I don't know if it is a bug or if it is a wanted behaviour in which case it should be explicited on the commerce documentation.

Hi, I have same sort of usecase. I have two shipping services:
Shipping within The Netherlands
Shipping outside The Netherlands

When I add to both the right condition:
Shipping within The Netherlands If Shipping.Address.Country = NL
Shipping outside The Netherlands If NOT Shipping.Address.Country = NL
Then only Shipping outside The Netherlands shows

If I remove on Shipping within The Netherlands If Shipping.Address.Country = NL
Then both Shipping Services are clickable again.

Somehow the Condition If Shipping.Address.Country = NL doesn't work correctly..

Underneath the exported Rules:
Shipping within The Netherlands

{ "commerce_shipping_service_binnen_nederland" : {
    "LABEL" : "Rate Verzendkosten Binnenland",
    "PLUGIN" : "rule",
    "REQUIRES" : [ "commerce_order", "commerce_shipping" ],
    "USES VARIABLES" : { "commerce_order" : { "label" : "Volgorde", "type" : "commerce_order" } },
    "IF" : [
      { "commerce_order_compare_address" : {
          "commerce_order" : [ "commerce_order" ],
          "address_field" : "commerce_customer_shipping|commerce_customer_address",
          "address_component" : "country",
          "value" : "NL"
        }
      }
    ],
    "DO" : [
      { "commerce_shipping_service_rate_order" : {
          "shipping_service_name" : "binnen_nederland",
          "commerce_order" : [ "commerce-order" ]
        }
      }
    ]
  }
}

Shipping outside The Netherlands

{ "commerce_shipping_service_verzenden_buiten_nederland" : {
    "LABEL" : "Rate Buiten Nederland",
    "PLUGIN" : "rule",
    "REQUIRES" : [ "commerce_order", "commerce_shipping" ],
    "USES VARIABLES" : { "commerce_order" : { "label" : "Volgorde", "type" : "commerce_order" } },
    "IF" : [
      { "NOT commerce_order_compare_address" : {
          "commerce_order" : [ "commerce_order" ],
          "address_field" : "commerce_customer_shipping|commerce_customer_address",
          "address_component" : "country",
          "value" : "NL"
        }
      }
    ],
    "DO" : [
      { "commerce_shipping_service_rate_order" : {
          "shipping_service_name" : "verzenden_buiten_nederland",
          "commerce_order" : [ "commerce-order" ]
        }
      }
    ]
  }
}

Thanks for going into this!

Greetings, Martijn

Hi there,

I followed like this video tutorial.

http://www.youtube.com/watch?v=ViS2xFvnZwc&feature=related

But I am facing a problem. It is the shipping service is not show at the shipping service.

This is my print screen.
http://i993.photobucket.com/albums/af56/thar5oe/Screenshotat2012-04-1522...
http://i993.photobucket.com/albums/af56/thar5oe/Screenshotat2012-04-1522...

please I need some help.

Regards
tharsoe

Title:Shipping service not selectedShipping service not selected (various issues with Rules configuration)
Category:bug» support
Status:Active» Fixed

Regarding the original post, the problem is your price comparison is using Euros instead of Cents. You would have had to compare against 40000 to be comparing against 400 €. However, as of Commerce 1.4, there is now a Price comparison condition that you can be using instead, and it supports entering price values in their major currency units. Change to that and you should be set.

@Summit - I'm pretty sure your issue was just one of the country not being set for an order yet. With automatic shipping rate recalculation in the full Shipping 2.0 release working now, your shipping rates should update as customers enter their shipping data, showing the proper shipping services based on the country.

@tharsoe - Sorry, I'm not sure what you're asking. It looks like you just don't have any shipping services available. Double check your conditions to make sure that at least one is visible at any given time.

@rszrama: indeed, as I wrote on #1 and #2 I've discovered it soon and I've learned how to manage this kind of comparison some day after reporting the original post. I didn't check the documentation recently but at the time I've had to read the source code to understand the process. Eventually (if not yet documented) a small note could be added on the Commerce docs or in the UI.

Thanks again :-)

hehe Glad you got it sorted out. Hopefully with the new Price comparison condition it'll make things a lot easier for folks. Not only does it use decimal currency values, but it can even handle multicurrency comparison. : )

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.