Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Payment method depend on shipping method

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 03-02-2021, 08:33 AM
 
libyapages libyapages is offline
 

Member
  
Join Date: Mar 2017
Posts: 15
 

Default 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
__________________
Hakim Elkharbash
Reply With Quote
  #2  
Old 03-04-2021, 02:21 AM
 
Ed B. Ed B. is offline
 

X-Adept
  
Join Date: Apr 2016
Posts: 446
 

Default 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?
__________________
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote
  #3  
Old 03-04-2021, 06:28 AM
 
libyapages libyapages is offline
 

Member
  
Join Date: Mar 2017
Posts: 15
 

Default 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
__________________
Hakim Elkharbash
Reply With Quote
  #4  
Old 03-04-2021, 11:03 AM
 
Ed B. Ed B. is offline
 

X-Adept
  
Join Date: Apr 2016
Posts: 446
 

Default 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.
__________________
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote
  #5  
Old 03-09-2021, 07:29 PM
 
libyapages libyapages is offline
 

Member
  
Join Date: Mar 2017
Posts: 15
 

Default Re: Payment method depend on shipping method

Solve it
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.
__________________
Hakim Elkharbash
Reply With Quote

The following user thanks libyapages for this useful post:
Ed B. (03-10-2021)
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:05 AM.

   

 
X-Cart forums © 2001-2020