The attached patch hopes to address the @todo "Rework this function to support any number of Express Checkout rules."

Currently the module looks at/for the explicit default Commerce PayPal EC Rule named "commerce_payment_paypal_ec" to determine if the module is enabled (via commerce_paypal_ec_enabled()).

In my use case, this prevents the display of the "Checkout with PayPal" button on the cart page when some orders (non-default currency, non-default country) need to use an alternate PayPal account (a custom PayPal EC rule).

Thanks!

CommentFileSizeAuthor
commerce_paypal_ec-multiple_rules.patch1.57 KBkrlucas
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chrisrockwell’s picture

Hey krlucas, have you implemented this in production at all? Especially with Domain, this is pretty critical functionality.

chrisrockwell’s picture

Just a quick heads-up. This patch addresses your issue, but I think another issue is when someone is using a multi-site setup and different sites need to use different Paypal Express accounts.

So, in addition to your modifications to `commerce_paypal_ec_enabled()` some changes to `commerce_paypal_ec_form_alter()` are necessary as the rule is hardcoded there as well.

The rough fix is:

// already know that paypal_ec is enabled, need the correct rule
        $keys = array_keys($order->payment_methods);
        foreach ($keys as $key) {
          if (strpos($key, 'paypal_ec') === 0) {
            $_payment_method = $order->payment_methods[$key];
          }
        }
        // Add the Express Checkout form as a suffix to the cart form.
        $payment_method = commerce_payment_method_instance_load('paypal_ec|' . $_payment_method['rule_name']);

I'll clean this up and submit a proper patch and, combined, they should address the major use cases.