I have a scenario where certain shipping / payment combinations are invalid. Ideally would like to see a valid payment options parameter against shipping options and corresponding validation as part of the core code. However, in the absence of such have been able to achieve this as follows:
Using following checkout workflow:
cart_coupon,login,address,shipping,payment,confirm_cart_coupon_status_fields,end
Have a
delivery and installation shipping plug-in which takes a price type parameter of either
please quote or
price from. If selected certain payment methods become inappropriate until after a quote has been submitted and agreed (e.g. paypal).
Needed to make a simple mod to the
step.php template to prevent people jumping ahead in the workflow (in the default template although steps are greyed out they are still clickable links).
Another simple mod to the paypal plug-in makes it unavailable if the
delivery and installation shipping option is selected:
function onPaymentDisplay(&$order,&$methods,&$usable_methods){
switch (@$order->shipping->shipping_params->shipping_price_type) {
case 'quote' :
case 'from' :
return false;
default:
break;
}
if(!empty($methods)){ ... etc ...
This works exactly as I want provided that the customer goes through the checkout workflow (both forwards and backwards) in the normal way using the
next button or the
step links. However, it is still possible for a customer to get into steps 5 / 6 and create the order by playing with the URL.
To prevent this I have been looking at the
onBeforeOrderCreate() method for the payment plugin.
However, although the shipping method name is provided in $order the shipping parameters are not.
Would it be possible to add these details to the $order object please (they are provided when
onPaymentDisplay() is called).