I have simple rule based on address comparison designed to apply a flat shipping rate and change the shipping page properties to advise the buyer that an manual shipping quote needs to be requested. (The business logic being that the shop owner would manually update the flat rate shipping amount and then the buyer would resume checkout.)

I know the rule is firing because of a the inclusion of a status message, but the 'Change page property' actions are not being triggered. Tested with Commerce Kickstart 7.x-2.20 (Rules 7.x-2.7) (Commerce Rules Extra 7.x-2.1)

Any suggestions about what I am doing wrong?

Here is the rule

{ "commerce_shipping_service_subject_to_quotation" : {
    "LABEL" : "Shipping rate subject to quotation",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "commerce_order", "commerce_rules_extra", "rules" ],
    "USES VARIABLES" : { "commerce_order" : { "label" : "Order", "type" : "commerce_order" } },
    "IF" : [
      { "commerce_order_compare_address" : {
          "commerce_order" : [ "commerce_order" ],
          "address_field" : "commerce_customer_shipping|commerce_customer_address",
          "address_component" : "country",
          "value" : "DE"
        }
      }
    ],
    "DO" : [
      { "commerce_rules_extra_change_page" : {
          "page_id" : "shipping",
          "help" : "Shipping Quote Required: Your order requires a shipping quote, please await an email with a shipping quote and check out afterwards.",
          "submit_value" : "Shipping Quote Required"
        }
      },
      { "drupal_message" : { "message" : "Shipping quote required" } }
    ]
  }
}

And here is the log

0 ms Reacting on event Collecting shipping rates for an order.
0.447 ms Evaluating conditions of rule Collect rates: Flat rate. [edit]
0.462 ms AND evaluated to TRUE.
" Rule Collect rates: Flat rate fires. [edit]
0 ms Rule Collect rates: Flat rate fires.
0.175 ms Evaluating the action commerce_shipping_method_collect_rates. [edit]
  " Executing rule Rate Express Shipping. [edit]
  " Executing rule Rate Free Shipping. [edit]
  " Executing rule Rate Standard Shipping. [edit]
  " Executing rule Rate Subject to quotation. [edit]
      0 ms Executing rule Rate Subject to quotation.
      0.28 ms Evaluating conditions of rule Rate Subject to quotation. [edit]
      4.245 ms The condition commerce_order_compare_address evaluated to TRUE [edit]
      4.27 ms AND evaluated to TRUE.
      " Rule Rate Subject to quotation fires. [edit]
        0 ms Rule Rate Subject to quotation fires.
          16.11 ms Evaluating the action commerce_rules_extra_change_page. [edit]
          16.288 ms Evaluating the action drupal_message. [edit]
          16.516 ms Rule Rate Subject to quotation has fired.
        20.875 ms Finished executing of rule Rate Subject to quotation.
      28.152 ms Rule Collect rates: Flat rate has fired.
    28.662 ms Finished reacting on event Collecting shipping rates for an order.

Comments

Perignon’s picture

Quick question. So the shipping address to trigger this is Germany?

Next question. What is the weight of the rule?

I need to get some Documentation started on D.O about this module and Rules in general with Drupal Commerce. I have found that rule weight is very, very important with a shopping cart checkout.

If you took the default weight of 0 I would suggest trying to bump that up to a higher number, like 10. There are a lot of rules that are weight 0 that come default with Drupal Commerce. So much so that often some rules will not process if they aren't set to process later (higher number).

MrPaulDriver’s picture

Yes, DE=Germany, although I was only using this for testing purposes and actually it's not a rule but a (shipping rate) component and from what I can see there is no weight value for components.

To be honest, I am flapping about a bit with this. My use case is for buyers located at a shipping address for where there is no shipping rate available and for where the shop owner would need to manually quote/add a shipping rate to an order before the buyer completed checkout. The trouble is, there does not seem to be a suitable way of preventing checkout before a shipping rate has been added to the order.

I was hoping that the checkout page properties could be changed somehow to ask buyers not to checkout, but this is not a good solution really.

Ideally what is needed is for the checkout button (continue to next step) to be disabled based on order status. This way a rule could change the order status to (say) 'request for shipping quotation' when the address conditions have been met and once the status has been changed to (say) 'shipping rate quoted' the checkout button could be made to display again. A few emails fly about and when the buyer returns to their cart they see a quoted shipping rate.

Would it be too much too ask for an additional action for this fine module? Disable/enable checkout submit button?

Perignon’s picture

@MrPaulDriver I think that would be possible to make an action that disabled the button. At the moment I am also in development of another module (CDN optimized JW Player) so I my time isn't as much as normal. But I will start looking into it. I think it might be fairly easy by doing a hook_form_alter() on the checkout form to remove the button to checkout.

MrPaulDriver’s picture

Category: Support request » Feature request

That would be a huge help

Perignon’s picture

Assigned: Unassigned » Perignon
Perignon’s picture

Title: Change page properties Actions not triggered » Action to disable the checkout button

Renaming the issue to be descriptive of the feature request.

Perignon’s picture

Update. Still working on this but haven't put a lot down in code yet.

  • Perignon committed 77308d0 on 7.x-2.x-2422839-action_disable_checkout
    Issue #2422839: Action to disable the checkout button
    
Perignon’s picture

I have created a new branch to develop the feature within.

  • Perignon committed 8f8d565 on 7.x-2.x-2422839-action_disable_checkout
    Issue #2422839: Removed code copied from other action
    
MrPaulDriver’s picture

Thanks for looking at this.

Jason.bellmt’s picture

What I've done in the mean time is set up a rule to redirect the user to a webform page when the postal code doesn't meet an approved list. It's not a prefect solution but it works for my problem

Perignon’s picture

Status: Active » Closed (outdated)

Please feel free to contribute code or ping if this is still desired.