Limit a payment module to certain products, etc.

Developer
از کشور United States
عضو از مارس 2021

Can one limit a payment module (like Paypal, or Stripe) to a specific product, custom option, currency, etc?

I have products that I would like to discount when using a specific payment module (that I'm writing...it is Bitcoin-based). I would like to charge a premium for Paypal and Stripe (or discount for Bitcoin, etc.).

I'm currently looking into using either Geo Zones (payment modules can be limited to Geo Zones) or currency (if I setup Bitcoin as a currency in the system). Or I would be interested in just applying a percentage discount for a specific payment module.

Let me know if that's not a clear enough description of my situation. Many thanks.

tim
Founder
از کشور Sweden
عضو از مهٔ 2013
tim

Sure you can limit a payment module to certain conditions.

Just have options() return nothing and the option will not be shown.

Currency
if (currency::$selected['coode'] != 'XXX') return;

Products
if (!in_array(123, array_column($items, 'product_id'))) return;

Stock Options
if (!in_array('11-22', array_column($items, 'option_stock_combination'))) return;

If you return an error with the option the module will be visible but disabled. See the wiki article for creating payment modules.

Developer
از کشور United States
عضو از مارس 2021

I would be interested in introspecting the items attributes as selected or entered by the customer...I would really appreciate an example of that based off of the $items array.

tim
Founder
از کشور Sweden
عضو از مهٔ 2013
tim

Step through them like this:


  if (empty($item['options'])) continue;
  foreach ($item[options] as $attribute_name => $attribute_value) {
    var_dump($attribute_name, $attribute_value);
  }
}```
شما
This website uses no cookies and no third party tracking technology. We think we can do better than others and really think about your privacy.