BuddyDev

Search

[Resolved] Pay Per Post by selling access with WooCommerce

  • Participant
    Level: Master
    Posts: 196
    Niculae Constantinescu on #46232

    Hi Tosin,

    Thank you for your involvement.
    Should I use both codes together?

    @brajesh What is your opinion?

    Thank you
    Cristi

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #46236

    Hi Tosin,
    The code has no performance issue. Clearing cart has no impact on performance(even if you have persistent cart enabled, it will only clear one user meta in that case).

    I will suggest 2 changes for sure
    1. Instead of using $wooocommerce, a better option would be to use

    
    WC()->cart->empty_cart()
    
    

    It is the same thing but safer.

    2. The above code will clear the cart when the visit that specific page, irrespective of whether a user intends to write post or not.

    A betters solution will be to clear cart before the post is published. Ravi or I will share a snippet for the same later today.

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #46239

    Hi Brajesh

    I had to add the value (true) to get it to work

    WC()->cart->empty_cart( true );

  • Participant
    Level: Master
    Posts: 196
    Niculae Constantinescu on #46246

    Hi Brajesh
    I am looking forward for the snippet.
    Thank you
    Cristi

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #46256
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #46257

    Hi Cristi, Tosin
    Please upgrade to 1.0.2 and then add the following code

    
    // clear cart before adding the product 
    add_action( 'bblpro_ppp_before_add_to_cart', function () {
    	WC()->cart->empty_cart( true );
    } );
    
    

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #46259

    Hello,

    1. @ravisharma thanks for the update I have tested the plugin and everything works perfectly now.

    2. @brajesh your snippet also works smoothly for emptying cart.

    Thanks

  • Participant
    Level: Master
    Posts: 196
    Niculae Constantinescu on #46261

    Hi,

    Everything is perfect.

    However it does not delete the images after deleting the article.
    I have this plugin installed;
    https://wordpress.org/plugins/dx-delete-attached-media/

    Should I make any other setting in BuddyBlog Pro, or change the plugin for deleting the images?

    Thank you
    Cristi

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #46263

    Hi Brajesh

    This code no longer works

    
    /**
     * Assign (Sponsored Post) category to BuddyBlog pay per post articles on checkout.
     */
    add_action( 'bblpro_ppp_post_published', function( $post_id ) {
    	$post_type = get_post_type( $post_id );
    	if ( 'post' != $post_type ) {
    		return;
    	}
    	// Get category.
    	$newcat = get_term_by( 'name', 'Sponsored posts', 'category' );
    	if ( ! $newcat ) {
    		return;
    	}
    	wp_set_post_categories( $post_id, $newcat->term_id, true );
    } );
    
  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #46271

    Hi Cristi,
    We will be looking at the attachment issue in general(BuddyBlog Pro) next week. It seems to have no co-relation with the Pay Per Post.

    Regards
    Brajesh

The topic ‘ [Resolved] Pay Per Post by selling access with WooCommerce’ is closed to new replies.

This topic is: resolved