• Resolved mistermax13

    (@mistermax13)


    Hello,

    First of all, THANKS. I’ve been struggling with a lot of plugins, including multivendors ones, to achieve very simple functionalities. It was like hell.
    Eventually, all I have to do is letting visitors send posts, and put a price on those posts. Easy, but it couldn’t be that easy without your plugin. Thanks.

    Now, I’m still stuck to the PHP part.
    When visitors send a new post on my plugin, I want to put a fixed price to access it. I already have a PHP custom code that runs every time that happens.
    I have a template product for that, I duplicate it, but I don’t manage to create a restriction with the duplicated product and the post that the visitor just sent.

    My code looks like that, it’s total improvisation but it should show in some way what I’m trying to achieve

            $wc_adp = new WC_Admin_Duplicate_Product;
            $dproduct = $wc_adp->product_duplicate( wc_get_product( '2726' ) ); # TEMPLATE one
            
    
            # NOT WORKING RIGHT NOW
            # using this new product with /sitewp/wp-content/plugins/woocommerce-pay-per-post/public/class-woocommerce-pay-per-post-restrict-content.php
            $restrict = new Woocommerce_Pay_Per_Post_Restrict_Content($post_id);
            array_push($restrict->product_ids, $dproduct->id);

    What should I do? Any idea?

    Thank you!

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Matt Pramschufer

    (@mattpramschufer)

    So the first thing I would do is look at the database level for the post_meta associated with your copied page. Make sure they post_meta looks the same as your original you are cloning, as I have a feeling you might only be copying the post and not the full post_meta

    Thread Starter mistermax13

    (@mistermax13)

    Hi Matt, thanks for this advice !

    In the DB my template product and my duplicated product look the same in the postmeta table.
    Actually, I am happy as soon as I have a duplicated product with the right price, I don’t want to use more features. ??

    Now, do you know how to add a restriction to the newly created post, using this newly created product?
    I know how to do this on the admin interface, but I have no clue in PHP.

    Thanks!

    Plugin Author Matt Pramschufer

    (@mattpramschufer)

    Its all in the database, what I can suggest is to look at the post_meta table on the post that is being protected, you need to look at wc_pay_per_post_product_ids and make sure to add the product that you are associating with the post ID in there.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add a restriction through PHP’ is closed to new replies.