Created
July 1, 2014 19:46
-
-
Save claudiosanches/cdf77f6b2be0a6d92937 to your computer and use it in GitHub Desktop.
Custom PayPal Adaptive Payments args
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Custom PayPal Adaptive Payments args. | |
* | |
* @param array $args | |
* @param WC_Order $order | |
* @return array | |
*/ | |
function custom_woocommerce_paypal_ap_payment_args( $args, $order ) { | |
$args['receiverList'] = array( | |
'receiver' => array( | |
array( | |
'amount' => '40.00', | |
'email' => '[email protected]', | |
// 'primary' => 'true' // use this only for Chained Payment. | |
) | |
), | |
'receiver' => array( | |
array( | |
'amount' => '15.00', | |
'email' => '[email protected]' | |
) | |
), | |
'receiver' => array( | |
array( | |
'amount' => '60.00', | |
'email' => '[email protected]' | |
) | |
) | |
); | |
return $args; | |
} | |
add_filter( 'woocommerce_paypal_ap_payment_args', 'custom_woocommerce_paypal_ap_payment_args', 10, 2 ); |
When is this filter triggered? Is there a way to set the receivers on product creation?
Neovea is correct. The example code displayed here is not valid. It is setting the same key 'receiver' multiple times on the same array, so only the last one will ever be recorded. I'm sure his fork addressed this. This page should be updated to avoid confusion.
If you get only last amount than try this code
EX:
$receivers => array(
array(
'amount'=>reviever amount FIRST here,
'email'=> reviever paypal FIRST email here here
),
array(
'amount'=>reviever amount SECOND here,
'email'=> reviever paypal SECOND email here here
),
array(
'amount'=>reviever amount THIRD here,
'email'=> reviever paypal THIRD email here here
)
);
$args['receiverList'] = array(
'receiver' => array($receivers)
);
return $args;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok. I figured it out :
It seems like the way the array is build messes up the payment. I forked the code with the correction if you want to check.
Thanks