• Resolved zain.mr89

    (@zainmr89)


    Hi,

    I found a topic related to multiple paypal accounts based on page id. But what I need to do is to add multiple paypal accounts and the payment is done according to category type.
    For example: Category A and category B will be purchased using paypal account number 1 while category C products purchased amount will go to paypal account number 2.

    Any help or just a simple idea would be highly appreciated.
    Thank you friends.

    https://wordpress.org/plugins/woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter zain.mr89

    (@zainmr89)

    I’ve done this. Sharing the code for others to get help 🙂

    Add below code in “plugins\woocommerce\includes\gateways\paypal\includes\class-wc-gateway-paypal-request.php”

    in the function “get_paypal_args” and replace “business => $this->gateway->get_option(email)” with “business => $business_email”

    global $woocommerce;

    // declare an array for the cart items category
    $cat_id = array();

    // get all cart items
    foreach ($woocommerce->cart->get_cart() as $cart_item_key => $values) {
    $_product = $values[‘data’];
    $terms = get_the_terms($_product->id, ‘product_cat’);

    foreach ($terms as $term) {
    $_categoryid = $term->term_id;
    }

    // insert each product category id in the array
    $cat_id[] = $_categoryid;
    }

    // check for the category of the products in the cart
    // 54 5 19 20 are all category id
    if (in_array(’54’, $cat_id)):
    $business_email = ‘custom-email@test.com’;
    elseif (in_array(‘5′, $cat_id) || in_array(’19’, $cat_id) || in_array(’20’, $cat_id)):
    $business_email = $this->gateway->get_option(’email’);
    else:
    $business_email = ”;
    endif;

    Hello Zain.mr89

    Thank you for your solution!

    However after made modifications i can’t validate my order, on checkout it’s say: Internal Server Error

    Have you made some modifications with your code since this last post?

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple paypal payment account based on product category’ is closed to new replies.