Force a payment method?

  • Posts: 28
  • Thank you received: 1
9 years 4 months ago #207000

-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.x

Hi,

I have a little bit of a complex issue I am trying to sort out.

We currently have 2 Warehouses configured with products assigned to their appropriate warehouse...
1. Order
2. Pre-Order

We then have shipping methods that are tied to the warehouses...

Restricted to the Order warehouse:
1. US Shipping
2. Canadian Shipping
3. EU Shipping
4. International Shipping.

and...

Restricted to the Pre-Order warehouse:
5. Pre-Order US Shipping
6. Pre-Order Canadian Shipping
7. Pre-Order EU Shipping
8. Pre-Order International Shipping.

Finally we have two payment methods...
1. PayPal - Restricted to shipping methods 1-4
(We do this so that International users dont have to worry about credit card restrictions and transactions being blocked by their bank.)

2. Manual Credit Card - Restricted to shipping methods 5-8
(this is because the user is not actually charged until the product is shipped, and this can some times be a long ways out.)

This all works really well, right up until we get a mixed cart with products from multiple warehouses. The shipping results in two shipping methods being selected, which is expected. The payments is where it breaks down. We either need a way to force Credit Card method when a cart has a mixed order. So that we can only charge a credit card manually for the amount that is being shipped immediately.

Any suggestions?

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
9 years 4 months ago #207001

Hi,

The simplest would be to remove the shipping methods restriction on the manual credit card payment method.
That way, this payment method will always display.
Then, if PayPal is the first one (based on the ordering) it will be selected automatically by the system.
Finally, you want to edit the file "payment" of the view "checkout" via the menu display>views and add such code at the top:
<?php if(count($this->methods)==2) array_pop($this->methods); ?>

That will remove the second choice of the payment methods selection area when there are two payment methods found by the system.

The following user(s) said Thank You: TheBeacon

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

  • Posts: 28
  • Thank you received: 1
9 years 4 months ago #207089

Thank you much!

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

  • Posts: 28
  • Thank you received: 1
9 years 4 months ago #207104

After further inspection, it seems that payment method order is being determined by which product appears first in the cart so if the cart order is

1. Pre-Order Product
2. Order Product

the payment order method is regardless of (payment method ordering):

1. Credit Card
2. Paypal

if i reverse the order something is added to the cart, the payment order is reversed...

the result is when using array pop, the last method is being trimmed off regardless of what the ordering is and we result in the undesired payment method.

Last edit: 9 years 4 months ago by TheBeacon.

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

  • Posts: 28
  • Thank you received: 1
9 years 4 months ago #207119

so basically I need to figure out a way to sort the cart items by warehouse and I think this will do the trick

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
9 years 4 months ago #207136

Hi,

Ah I see, that's because you are redirected to the checkout when you add a product to the cart, so in that case, the only possible payment method is selected at that point.
Try to change the "when a product is added to the cart" setting to something else in order to not be redirected to the checkout directly.
That way, when you access the checkout with both products in the cart, it should work fine.

That's however not a foolproof solution so I don't recommend doing that.
A more complex customization of the code of the payment view would be necessary to check each payment method, hide the correct one all the time, and select the only one possible. That will it would work all the time, regardless of how you configure that "when a product is added to the cart" setting or what the customer do. But in that case, it's more complex than a 1 line code modification and will require a developer to spend some time customizing the code for you.

I don't see how changing something in the warehouse would do the trick though.

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

Time to create page: 0.062 seconds
Powered by Kunena Forum