Is there any way in expresso to check if the current user has purchased a particular product?

Something like, {if purchased}you own this{if:else}you don't own this{/if}



You will need Stash to get this working

Setting the stash

{if logged_in} {exp:store:orders member_id="CURRENT_USER" paid="yes"} {if is_order_paid} {exp:stash:append name="verify_product" trim="yes"} {items}{entry_id}|{/items} {/exp:stash:append} {/if} {/exp:store:orders} {/if}

Output the variables

Wrap exp:channel:entries loop with {exp:stash:parse process="end"}{/exp:stash:parse}

Inside the entries loop

{if "{exp:stash:verify_product}" ~ "/{entry_id}\b/"} You have already brought this map {if:else} {exp:store:product entry_id="{entry_id}" return="{current_path}"} {if qty_in_cart} This product is already in your cart. {if:else} {price} <input type="text" name="item_qty" value="1" /> <button type="submit">Add to cart</button> <button type="submit">Add to cart</button> {/if} {/exp:store:product} {/if}

Disclamer: You will need latest version of EE to use the Matches operator conditional

  • Thanks for your answer... I no longer work for the company that was building the site so.. yup... thanks anyway, good to know for any future projects.
    – magicspon
    Mar 26 '15 at 15:03
  • Cheers, leaving it here for reference :) Mar 26 '15 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.