nican VIP
Total posts: 392
16 May 2018 10:27

I hired a developer to solve an issue on my website, and I thought about sharing the solution with he community here :)

PROBLEM:

How to hide/show website content (anywhere on the website) based on the Hikashop and/or Emerald products a user bought

WHAT YOU NEED:

For this solution to work you need

  • The Pro version of Conditional Content plugin by Regular Labs (really easy to use, tutorials on their website)

  • The Plugin attached to this thread

HOW TO INSTALL:

The plugin must be uploaded manually to your website, instructions are in the plugin folder

EXAMPLE USAGE (this is the sintax you need to paste on your page):

Note: the plugin is written to check both Hikashop products and Emerald subscriptions, but you can just use it just for Hikashop or just for Emerald - BUT you need both installed on your website or you may receive fatal errors

Hikashop product (1)

You {show php="return hasBoughtHikashopProducts(51)"} have {show-else} haven't {/show} bought HIkashop product ID 51

Hikashop products (bought more than 1)

You {show php="return (hasBoughtHikashopProducts(51) && hasBoughtHikashopProducts(30))"} have {show-else} haven't {/show} bought product with ID 30 AND ID 51

Hikashop products (check array)

You {show php="return hasBoughtHikashopProducts(array(30,51))"} have {show-else} haven't {/show} bought Hikashop product ID 30 OR 51

Emerald subscription

{show php="return hasEmeraldSubscription(17)"}User has been subscribed to subscription ID 17{/show}

Emerald subscriptions (check array)

You {show php="return hasEmeraldSubscription(array(15,16))"} have {show-else} haven't {/show} bought Emerald 15 OR 16

Hikashop product OR Emerald subscriptions

You {show php="return (hasBoughtHikashopProducts(51) || hasEmeraldSubscription(15))"} have {show-else} haven't {/show} bought Hikashop 51 OR Emerald 15

Emerald subscription + Hikashop products array

{show php="return (hasEmeraldSubscription(17) && hasBoughtHikashopProducts(array(51, 52)))"}User has been subscribed to subscription ID 17 and bought product with ID 51 or ID 52{/show} Hope this will help!

conditionalcontentcheck-UNZIP-FIRST

Last Modified: 23 May 2018


Sergey
Total posts: 13,748
16 May 2018 11:39

Does that work? hasEmeraldSubscription(17) is not a function but a method of the class. I am not sure you can call it like this.


nican VIP
Total posts: 392
22 May 2018 18:47

As far as I have tested it works just fine

Powered by Cobalt