Hi, I need you to code two simple PHP snippets for WordPress/WooCommerce

Script #1 – Post Tag to Cookie
– Get current Post Tag (there will alway only be one post tag, not multiple)
— If no Post Tags are returned do nothing
— If Post Tag returned, save post tag to cookie (cookie name: woo_post_tag).

If the user visits another post and there is a different Post Tag, the value of the new post tag will be written into the "woo_post_tag" cookie (old value will be overwritten).

Script #2 – Product ID’s to Cookie
– Check if user is logged in (if not do nothing)
— Logged in? Yes: Check if user has role "customer" (if not do nothing)
— Role "customer"? Yes: Query and save all product ID’s he has bought into a cookie (cookie name: lp_ids). Product ID’s can be seperated by a (,) or (|) delimiter.

Right now I plan to load the 2nd script on every page load, which might not be good for performance. It would be enough to query product ID’s on page load every 30 minutes. If you have any better idea on how to solve this, please tell me in your application. Thanks.

More info for the cookie: The snippet (for script #2) will be put onto a subdomain (courses.test.com) with WooCommerce installed, but the data of the cookie also needs to be available on the main page (test.com).

You can use our test environment for your snippets. Will send WordPress credentials after you apply.

If you have any questions, please ask them in your application. Thanks for your time in advance.

Budget: $15

Posted On: February 18, 2022 14:12 UTC
Category: CMS Development
Skills:WordPress, PHP

Country: Germany

click to apply