in WC4BP Premium, Version 3.0.16
In the file "wc4bp-helpers.php", the action "wc4bp_loader_purchase_activity" has an if condition "is_user_logged_in" . This condition blocks adding purchase BP activity in case of paiement on checkout plateform such as Paybox with IPN (Instant Payment Notification).
I removed this condition.
In addition, as far I know, there is also a useless if condition on get_user_id() == get_customer_id().
Useless since one is an alias of the other.
See below proposed modification
line 188
function wc4bp_loader_purchase_activity( $order_id ) {
try {
/remove next condition to allow Paybox IPN notification to add activity : start /
/
if ( ! is_user_logged_in() ) {
return false;
}
/
/ remove next condition to allow Paybox IPN notification to add activity : end /
if ( ! bp_is_active( 'activity' ) ) {
return false;
}
$order = new WC_Order( $order_id );
if ( $order->get_status() != 'completed' ) {
return false;
}
/*remove next condition since get_user_id is an alias of gest_customer_id : start */
/*
if ( $order->get_user_id() != $order->get_customer_id() ) {
write_log('ATFY: inside wc4bp_loader_purchase_activity : user not customer');
return false;
}
*/
/* remove next condition since get_user_id is an alias of gest_customer_id : end */
$user_link = bp_core_get_userlink( $order->get_customer_id() );
// if several products - combine them, otherwise - display the product name
$products = $order->get_items();
$names = array();
foreach ( $products as $product ) {
$names[] = '<a href="' . $product->get_product()->get_permalink() . '">' . $product->get_product()->get_name() . '</a>';
}
// record the activity
bp_activity_add( array(
'user_id' => $order->get_user_id(),
'action' => apply_filters( 'wc4bp_loader_purchase_activity_action',
sprintf(
__( '%s purchased %s', 'wc4bp' ),
$user_link,
implode( ', ', $names )
),
$order->get_user_id(),
$order,
$products
),
'component' => 'shop',
'type' => 'new_shop_purchase',
) );
} catch ( Exception $exception ) {
WC4BP_Loader::get_exception_handler()->save_exception( $exception->getTrace() );
}
}
// todo: Add option to the admin to deactivate activity integration
add_action( 'woocommerce_order_status_completed', 'wc4bp_loader_purchase_activity' );
in WC4BP Premium, Version 3.0.16 In the file "wc4bp-helpers.php", the action "wc4bp_loader_purchase_activity" has an if condition "is_user_logged_in" . This condition blocks adding purchase BP activity in case of paiement on checkout plateform such as Paybox with IPN (Instant Payment Notification). I removed this condition. In addition, as far I know, there is also a useless if condition on get_user_id() == get_customer_id(). Useless since one is an alias of the other. See below proposed modification
line 188 function wc4bp_loader_purchase_activity( $order_id ) { try { /remove next condition to allow Paybox IPN notification to add activity : start / / if ( ! is_user_logged_in() ) { return false; } / / remove next condition to allow Paybox IPN notification to add activity : end /
}
// todo: Add option to the admin to deactivate activity integration add_action( 'woocommerce_order_status_completed', 'wc4bp_loader_purchase_activity' );