I want to offer 2 shipping options: a real one (flat rate) and "in store pick up" which obviously doesn't require the shipping address.
Is there any way to enable/disable the "shipping profile" checkout pane using just some custom shipping method code? I couldn't find a useful example on how to do it so I'm kinda stuck.
Currently I can unconditionally disable the pane using hook_commerce_checkout_pane_info_alter($checkout_pane) but i don't know how to lookup the shipping method that was selected (shipping profile pane is on the 'review' page, shipping is at 'checkout').
function mymodule_commerce_checkout_pane_info_alter(&$checkout_pane) {
if(<strong>$no_actual_shipping_needed</strong>) {
$checkout_pane['customer_profile_shipping']['enabled'] = 0;
}
}
I need some directions, please.
Comment | File | Size | Author |
---|---|---|---|
checkout-settings-screen.jpg | 30.69 KB | scoff |
Comments
Comment #1
scoff CreditAttribution: scoff commentedOk, here's the working code, but I'm not sure if it's the best way possible. Also I'm not sure how dependable is that $order->data['shipping_method'].
It works if the shipping profile pane is on a separate checkout page that appears after the shipping method is set.
Comment #2
googletorp CreditAttribution: googletorp commentedClosing
Comment #4
UrmasZ CreditAttribution: UrmasZ commentedI can't get this code working:
Notice: Undefined index: shipping_method in mymodule_commerce_checkout_pane_info_alter() (line 34 of ............./sites/all/modules/mymodule/mymodule.module). Backtrace:
mymodule_commerce_checkout_pane_info_alter(Array, NULL, NULL) module.inc:1022
drupal_alter('commerce_checkout_pane_info', Array) commerce_checkout.module:494
commerce_checkout_panes(Array) commerce_checkout.module:402
commerce_checkout_pages() commerce_checkout.module:287
commerce_checkout_commerce_order_status_info()
call_user_func_array('commerce_checkout_commerce_order_status_info', Array) module.inc:823
module_invoke_all('commerce_order_status_info') commerce_order.module:1103
commerce_order_statuses(Array) commerce_cart.module:678
commerce_cart_order_is_cart(Object) commerce_cart.module:534
commerce_cart_commerce_order_load(Array)
call_user_func_array('commerce_cart_commerce_order_load', Array) entity.inc:334
DrupalDefaultEntityController->attachLoad(Array, ) commerce_order.controller.inc:121
CommerceOrderEntityController->attachLoad(Array, ) entity.inc:204
DrupalDefaultEntityController->load(Array, Array) common.inc:7623
entity_load('commerce_order', Array, Array, ) commerce_order.module:775
commerce_order_load_multiple(Array, Array) commerce_order.module:744
commerce_order_load('1') menu.inc:592
_menu_load_objects(Array, Array) menu.inc:759
_menu_translate(Array, Array) menu.inc:471
menu_get_item() menu.inc:1751
menu_get_custom_theme(1) menu.inc:1766
menu_set_custom_theme() common.inc:5043
_drupal_bootstrap_full() bootstrap.inc:2186
drupal_bootstrap(7) index.php:20
And I am not smart enough to fix it. Can someone help? :)
Having option to hide panes based on shipping method is so much needed functionality!
Comment #5
googletorp CreditAttribution: googletorp commented#4 Try to Q&A section on drupalcommerce.org
Comment #6
switch13 CreditAttribution: switch13 commentedcheck out this tread for more info:
http://www.drupalcommerce.org/questions/3304/how-hide-checkout-panes-bas...