shipping / payment method conflicts

  • Posts: 292
  • Thank you received: 5
  • Hikashop Business
13 years 3 months ago #5786

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).

Please Log in or Create an account to join the conversation.

  • Posts: 81677
  • Thank you received: 13102
  • MODERATOR
13 years 3 months ago #5794

In the function onBeforeOrderCreate, the variable $order->cart will be the equivalent of the object $order in the function onPaymentDisplay.

In the function onPaymentDisplay, the $order object is a snapshot of all the information about the current cart. In the function onBeforeOrderCreate, the variable $order is really the data which will be saved in the database by the order class for the order ( the objects inside it are ignored automatically ), and the cart sub object is added to it specifically for such cases where you would need more information.

Please Log in or Create an account to join the conversation.

  • Posts: 292
  • Thank you received: 5
  • Hikashop Business
13 years 3 months ago #5803

Perfect, thanks, I had not drilled down far enough in the variables.

Please Log in or Create an account to join the conversation.

Time to create page: 0.067 seconds
Powered by Kunena Forum