X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Payment method depend on shipping method (https://forum.x-cart.com/showthread.php?t=78164)

libyapages 03-02-2021 08:33 AM

Payment method depend on shipping method
 
Hey
I try to make payment method depend on the shipping method, I follow this article: https://devs.x-cart.com/changing_store_logic/making_payment_method_depend_on_shipping_method.ht ml

For some reason $this->getShippingMethodName() does not return any value, Have anyone had same issue? any suggestions??

Thanks

Ed B. 03-04-2021 02:21 AM

Re: Payment method depend on shipping method
 
I can confirm that the module is working fine on my dev store (5.4.1.24)


How does your shipping methods page ( admin.php?target=shipping_methods ) look?

libyapages 03-04-2021 06:28 AM

Re: Payment method depend on shipping method
 
Thanks for responding.

Yes, I believe it's working fine in standard X-Cart, but I use X-Cart Multivendor, which has the issue. When I dig more, I figured out that Multivendor has no method to get shipping method name as in standard X-Cart.

I have tried to add such a method to my one module but I still have an issue getting the ShippingId.

Any suggestions??

Thanks

Ed B. 03-04-2021 11:03 AM

Re: Payment method depend on shipping method
 
I am sorry but I don't have Multivendor X-Cart code, so I don't know how things work. However, presumably you should take a look at the code of Model/Order.php, or whichever class that might be overriding it.

libyapages 03-09-2021 07:29 PM

Re: Payment method depend on shipping method
 
Solve it :D
it turns out that X-Cart handles orders in Multi-Vendor as Children, where each child represents a vendor. Therefore, to access methods we need first to specify the child (vendor).

So instead of:
PHP Code:

$this->getShippingMethodName(); 


We need to use:
PHP Code:

$this->getChildren()[0]->getShippingMethodName(); 

Where [0] => first child (vendor) of the order.


All times are GMT -8. The time now is 10:52 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.