Index: openacs-4/packages/ecommerce/www/checkout-3.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/checkout-3.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/packages/ecommerce/www/checkout-3.tcl 4 Sep 2008 12:24:06 -0000 1.11 +++ openacs-4/packages/ecommerce/www/checkout-3.tcl 17 Dec 2008 06:19:58 -0000 1.12 @@ -93,24 +93,32 @@ select shipping_address from ec_orders where order_id=$order_id" -default ""] -if { [empty_string_p $address_id] } { +# Check if the order requires shipping + +if {[db_0or1row shipping_avail " + select p.no_shipping_avail_p + from ec_items i, ec_products p + where i.product_id = p.product_id + and p.no_shipping_avail_p = 'f' + and i.order_id = :order_id + group by no_shipping_avail_p"]} { + + set shipping_required 1 +} else { + set shipping_required 0 +} + +if { [empty_string_p $address_id] && $shipping_required } { + # No shipping address is needed if the order only consists of soft # goods not requiring shipping. - - if {[db_0or1row shipping_avail " - select p.no_shipping_avail_p, count (*) - from ec_items i, ec_products p - where i.product_id = p.product_id - and p.no_shipping_avail_p = 'f' - and i.order_id = :order_id - group by no_shipping_avail_p"]} { - ns_log Notice "checkout-3.tcl ref(110): no shipping address needed for order_id:$order_id, redirecting to checkout" + ns_log Notice "checkout-3.tcl ref(110): shipping address needed for order_id:$order_id, redirecting to checkout" ad_returnredirect [ec_securelink [ec_url]checkout] - ad_script_abort - } + ad_script_abort } + # Make sure there is a credit card (or that the # gift_certificate_balance covers the cost) and a shipping method for # this order, otherwise they've probably gotten here via url surgery, @@ -143,7 +151,9 @@ select shipping_method from ec_orders where order_id=:order_id" -default ""] -if { [empty_string_p $shipping_method] || ([empty_string_p $creditcard_id] && [exists_and_equal gift_certificate_covers_cost_p "f"]) } { + +if { ([empty_string_p $shipping_method] && $shipping_required) || ([empty_string_p $creditcard_id] && [exists_and_equal gift_certificate_covers_cost_p "f"]) } { + ns_log Notice "checkout-3.tcl ref(146): no shipping method for order_id:$order_id. Redirecting to checkout-2" rp_internal_redirect checkout-2 ad_script_abort