mishochu Developer Depuis United States Membre depuis mars 2021 mishochu 8 juin 2022 03:17 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 Depuis Sweden Membre depuis mai 2013 tim 8 juin 2022 16:42 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.
mishochu Developer Depuis United States Membre depuis mars 2021 mishochu 8 juin 2022 20:09 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 Depuis Sweden Membre depuis mai 2013 tim 8 juin 2022 20:39 Step through them like this: if (empty($item['options'])) continue; foreach ($item[options] as $attribute_name => $attribute_value) { var_dump($attribute_name, $attribute_value); } }```