I had resolved.
Error is in the plugin “Affiliate Stripe Payments Integration Version 1.4”. It uses “item_price” which should use “paid_amount”
Plugin Author
mra13
(@mra13)
Thank you for this.
A slightly better calculation would be to do the following I think:
$amount = ($item_price * $item_quantity) - $tax_amt - $shipping_amt;
I have updated the addon with this fix. You can download it from the following page:
https://www.tipsandtricks-hq.com/wordpress-affiliate/stripe-payments-plugin-affiliate-platform-integration-1457
Yes, that would be better. Let me try it out….Thanks.
I tested. Calculation is error. That is due to when variant is used in stripe payment plugin. the plugin “Affiliate Stripe Payments Integration Version 1.5” did not calculate those.
Hence, I modified the code section as shown. I did not go further to find out those variant variable, for simple hack I just use the “paid amount” – [“tax amt” + “shipping amt”]:
=========================
`//Required Parameters
$item_price = $post_data[‘item_price’];//Sale amount
$item_quantity = isset($post_data[‘item_quantity’]) ? $post_data[‘item_quantity’] : 1;//Item quantity
$tax_amt = isset($post_data[‘tax’]) ? $post_data[‘tax’] : 0;//Tax amount if any;
$shipping_amt = isset($post_data[‘shipping’]) ? $post_data[‘shipping’] : 0;//Shipping amount if any;
$paid_amount = $post_data[‘paid_amount’];//Total Amount Paid
//Amount calculation (for commission purpose)
wp_affiliate_log_debug(‘Stripe Payments integration – Item price: ‘.$item_price.’, Item quantity: ‘.$item_quantity.’, Tax: ‘.$tax_amt.’, Shipping: ‘. $shipping_amt.’, Total Paid Amount: ‘.$paid_amount, true);
//$amount = ($item_price * $item_quantity) – $tax_amt – $shipping_amt;
$amount = $paid_amount – ($tax_amt + $shipping_amt);
=========================
Hope helpful.
You can account for the product price variations using the following code…
$varPrice = isset( $post_data['var_applied'] ) ? $post_data['var_applied'] : '';
// check if we have variations applied
if ( $varPrice ) {
$varPrice = array_sum(array_column($varPrice, 'price'));
}
I uses :
$varPrice = isset( $post_data['var_applied'] ) ? $post_data['var_applied'] : '';
// check if we have variations applied
if ( $varPrice ) {
$varPrice = array_sum(array_column($varPrice, 'price'));
}
and
set:
$amount = ($item_price * $item_quantity) + $varPrice - $tax_amt - $shipping_amt;
the commission is calculated based on incorrect amount.
Actual amt = 123.05 – tax – shipping = 115, instead it based on 106.05 to calculate commission.
Hi,
I am sorry of confusion… My calculation is wrong. Since the sum up price is before Tax and Shipping fee, hence the formulate should be:
$amount = ($item_price + $varPrice) * $item_quantity;
Should be good now. Thanks.