• Resolved jimlongo

    (@jimlongo)


    I have a main product that is required to be purchased (or submit proof of purchase) before buying other products.

    I have the “proof of purchase” requirement satisfied by submitting a code from your purchase receipt that stores a session variable $_SESSION[‘purchased’] = true. Then if this variable is true you can proceed to the all products page.

    If they don’t have a proof of purchase, How would I set this variable based on the (addition to the cart) of Product XYZ? Or is there a better way you can think of to accomplish this functionality?

    I do realize that people may remove it from the cart after having placed it there, but the client understands that possibility.

    http://wordpress.org/extend/plugins/woocommerce/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter jimlongo

    (@jimlongo)

    Here’s my thinking . . .
    in my plugin I put the following action hook

    add_action( 'woocommerce_cart_contents'  , 'nfp_purchased_photo');
    function nfp_purchased_photo() {
        if( $product_id == '1450' ){
            $_SESSION['purchased']= 'true';
        }
        else{
            continue;
        }
    }

    this is trying to hook into woo commerce/cart.php which has this
    do_action('woocommerce_cart_contents' );

    Of course that is not doing what I want.
    Any other hooks that you would think more appropriate?

    Hi,
    So product 1450 must either be in the cart, or the ‘proof of purchase’ function must have been satisfied, to either:
    (1) access the main product catalog
    or
    (2) checkout
    ??

    Thread Starter jimlongo

    (@jimlongo)

    It must be in the cart to access the main product catalog.

    If $_SESSION[‘purchased’] = ‘true’ then when you click the link it redirects to the main catalog, otherwise it redirects to the single product i want you to buy.

    why not apply the requirement at checkout time – easier to program, I think… that way they can see and use the catalog to add any product to cart, but can’t check out until ‘purchased’ is satisfied?

    Thread Starter jimlongo

    (@jimlongo)

    I suppose that’s a possibility. It depends on how user friendly the whole process is, I hate to make things difficult for customers.

    How would you accomplish that?

    Thanks.

    One approach would be to:
    (1)grab a copy of my plugin http://wordpress.org/plugins/minimum-purchase-for-woocommerce/
    (2) hack the core/vtmin-apply-rules.php file, function vtmin_minimum_purchase_check(), to do just what you want. Remove all of the function’s code, and then create new code to verify ‘purchased’ or loop through the cart class and verify if 1450 purchased. If not, add your message to the cart class with the following: $vtmin_cart->error_messages[] = array ('msg_from_this_rule_id' => $rule_id_list, 'msg_from_this_rule_occurrence' => '', 'msg_text' => $message );
    (3) the hacked plugin will do the rest, injecting the message in a nice format at the top of the cart.
    (4) create a ‘minimum purchase rule’ (which in this case will do your function only) to cover all user roles, to activate the works.

    and Bob’s your uncle, Fanny’s your aunt.

    Vark

    Thread Starter jimlongo

    (@jimlongo)

    I’ve been looking at your plug-in page and that’s pretty interesting.

    So in fact there are 4 products (1450, 1451, 1452, 1453) that could qualify you to checkout OR the proof of purchase code.

    I’ll give it a whirl and see where it goes. I wouldn’t mind paying for or donating to such a thing. Do I need the Min Pro version to apply to all the contents of the cart?

    Thread Starter jimlongo

    (@jimlongo)

    @varktech.com
    Your suggestion worked great! And I think it is both easier for the customer to understand and better from a sales perspective to let them see all the products as an incentive.

    Thanks for the advice.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘identify if particular product has been purchased’ is closed to new replies.