Replies
I have done as you instructed with is_user_loggdin() but now how can I resolve the performance issue with count_user_posts and simplify the code
Thanks
- Tosin on October 30, 2023 at 10:37 am in reply to: Buddyblog pay per post – how to delete pending oreders when draft is deleted #50807
Hello Ravi,
I have added the processing and on-hold but the code did not empty the cart when the unpaid (pending) post was deleted. I aslo tried both empty cart and delete order together with code below
function empty_cart_and_delete_order_on_pending_post_deletion( $post_id ) { $post = get_post($post_id); if ( ! $post ) { return; } if ($post->post_status === 'pending' && $post->post_type === 'post') { if (function_exists('bbl_ppp_get_post_order_id') && function_exists('wc_get_order')) { $order_id = bbl_ppp_get_post_order_id($post_id); if ($order_id) { $order = wc_get_order($order_id); if ($order && in_array($order->get_status(), array('processing', 'on-hold', 'pending', 'draft'))) { // Empty the cart WC()->cart->empty_cart(true); // Delete the pending order $order->delete_order(true); } } } } } add_action('before_delete_post', 'empty_cart_and_delete_order_on_pending_post_deletion');
This also did not work
- Tosin on October 27, 2023 at 10:58 am in reply to: Buddyblog pay per post – how to delete pending oreders when draft is deleted #50796
Gentle reminder sir thanks
- Tosin on October 20, 2023 at 11:13 am in reply to: Buddyblog pay per post – how to delete pending oreders when draft is deleted #50762
I tested the edited code but it did not work
- Tosin on October 20, 2023 at 11:03 am in reply to: Buddyblog pay per post – how to delete pending oreders when draft is deleted #50761
Thanks Ravi After giving this a better thought I think emptying woocommerec cart might be better so I edited your code
function empty_cart_pending_post_order( $post_id, $post ) { if ( empty( $post->post_type ) || 'post' !== $post->post_type ) { return; } if ( ! function_exists( 'bbl_ppp_get_post_order_id' ) || ! function_exists( 'wc_get_order' ) || ! function_exists( 'WC' ) ) { return; } $order_id = bbl_ppp_get_post_order_id( $post_id ); if ( $order_id ) { $order = wc_get_order( $order_id ); if ( $order && in_array( $order->get_status(), array( 'pending', 'draft' ) ) ) { // Empty the cart instead of deleting the order. WC()->cart->empty_cart(); } } } add_action( 'before_delete_post', 'empty_cart_pending_post_order', 10, 2 );
- Tosin on October 19, 2023 at 9:47 am in reply to: Buddyblog pay per post – how to delete pending oreders when draft is deleted #50758
Thanks for the feedback Ill like to proceed with this as my product setup is simple direct transactions and associated product orders only contain a single product related to the post. I set up 1 product per pricing. I dont use multiple products for the same order
I have this example code below
function delete_pending_post_order($post_id) { if (get_post_type($post_id) === 'post') { $order_id = get_post_meta($post_id, '_order_id', true); if ($order_id) { $order = wc_get_order($order_id); if ($order && in_array($order->get_status(), array('pending', 'draft'))) { $order->delete(true); } } } } add_action('before_delete_post', 'delete_pending_post_order');
- Tosin on September 21, 2023 at 3:14 pm in reply to: [Resolved] Buddypress follow plugin and buddypress 12.0.0 #50575
Hi Brajesh,
Please note that this issue is now resolved as the updated follow plugin at github now works without errors with buddypress 12.0.0 beta 2
KINDLY NOTE – The problem was caused by a specific plugin conflict with https://wordpress.org/plugins/mark-new-posts/ Its quite strange but immediately I deactivated Mark New Post plugin there was no more error with the buddypress follow plugin
Thanks
- Tosin on September 18, 2023 at 9:31 am in reply to: [Resolved] Buddypress follow plugin and buddypress 12.0.0 #50548This reply has been marked as private.
- Tosin on September 18, 2023 at 9:29 am in reply to: [Resolved] Buddypress follow plugin and buddypress 12.0.0 #50547This reply has been marked as private.
- Tosin on September 15, 2023 at 9:05 am in reply to: [Resolved] Buddypress follow plugin and buddypress 12.0.0 #50525
Ill keep you updated on further updates from imath