You must be logged in to view the page.×

Limit a payment module to certain products, etc.

Developer
Tól től United States
Tagság márc. 2021 óta

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
Tól től Sweden
Tagság máj. 2013 óta
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
Tól től United States
Tagság márc. 2021 óta

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
Tól től Sweden
Tagság máj. 2013 óta
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);
  }
}```
Te
Ez a weboldal nem használ cookie-kat és nem használ harmadik féltől származó nyomkövetési technológiát. Úgy gondoljuk, hogy jobban tudjuk csinálni, mint mások, és tényleg gondolunk az Ön magánéletére.