Author Topic: assign specific payment or shipment method to specific product  (Read 1138 times)

normangreen

  • Beginner
  • *
  • Posts: 5
hello

If I have three products named product-A, product-B, product-C and two payment methods named payment-I, payment-II and two shipment methods named shipment-1,shipment-2.

Then I want the product-C can only use the payment-II and shipmet-2, there is no other payment and shipment method(payment-I and shipment-1) for customers who buy product-C to choose.

My objective is to let the specific product in the checkout process can only use the specific payment or shipment method for coustomers.

How can I configure to achieve the objective?

Thank you.

rinopiponte

  • Beginner
  • *
  • Posts: 7
  • VM Developer
    • Design It
Re: assign specific payment or shipment method to specific product
« Reply #1 on: May 14, 2015, 10:20:40 am »
I had the very same problem in my shop, because I combine several kinds of products at http://design-it.es.

This is a trick, but you have to be very careful because it implies changing the code of virtuemart core

* For shipment its easy if you set different ranges of shipment depending on weight, for example Product A with shipment A only if PA weights less than 100Kg, PB with SB if it weights less than 50Kg and PC if it weight less that 25Kg. If you can set these conditions without impacting on other areas you have it solved. You have to change shipment plugin

* For payment you will have to change the code at /components/com_virtuemart/views/cart/tmpl/select_payment.php
For each product at line 26 you'll have to write

You have to set a tick for example if it is a category:
Code: [Select]
foreach ($this->cart->products as $pkey => $prow) {
if ( $prow->virtuemart_category_id == 'XXX'){
$TICK = 1;
}
}
 

or for a single product

Code: [Select]
foreach ($this->cart->products as $pkey => $prow) {
if ( $prow->product_name "Or $prow->url or whatever"== 'XXX'){
$TICK = 1;
}
}
 

Then depending on your shipment order, you'll have to select for each tick only the shipment method you want to display.

Do this only if you can code using php, and of course backup the modified files before changing a single character.

Hope this helps
**************************
VM Plugin Developements: http://design-it.es/diseno-web-extensiones
Website: http://design-it.es
**************************

reinhold

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 204
Re: assign specific payment or shipment method to specific product
« Reply #2 on: May 14, 2015, 12:36:58 pm »
Regarding shipping: With my Advanced Shipping by Rules plugin (http://open-tools.net/virtuemart/advanced-shipping-by-rules.html) it is realy easy to hide a shipping method if a particular product is in the cart.

You can make your shipping method unavailable for a product by prepending this rule to the method's rules for shipment-1:
Code: [Select]
Comment="No shipment-1 for product C"; contains_any(SKUs, "product-C"); NoShipping
...[here come your other rules for the shipping method]...
This will simply not offer the method if product C is in the cart. If product C is not in the cart, the method might offer shipping if the next rules match.

Regarding payment, I have no idea how you can easily implement this without modifying the VM code itself.

Best regards,
Reinhold

Dragoner

  • Beginner
  • *
  • Posts: 30
Re: assign specific payment or shipment method to specific product
« Reply #3 on: June 29, 2018, 13:17:35 pm »
Hi, is this funcional in vm3?

Code: [Select]
foreach ($this->cart->products as $pkey => $prow) {
if ( $prow->virtuemart_category_id == 'XXX'){
$TICK = 1;
}
}
 

Pls can you send me your file select_payment.php

Thank you
David

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3459
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y

Dragoner

  • Beginner
  • *
  • Posts: 30
Re: assign specific payment or shipment method to specific product
« Reply #5 on: July 25, 2018, 14:34:37 pm »
Shipment rule is nice, but i need only payment rules.

Somethink like this ... I have two products

Product 1 and product 2
Product 1 ... payment only by credit card
product 2 ... payment by credit cart and cash

If i get to cart product 1 and product to, payment must be only credit card ...
Is it possible?


Sorry for my english :)
Thanks David

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3459
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: assign specific payment or shipment method to specific product
« Reply #6 on: July 25, 2018, 14:50:32 pm »
You can use categories as filter in the shipment methods.
Check if the plugin developer can add this restrictions in your payment methods, so you can use categories to restrict the displayed methods.