is there any php function for the child theme or plugin that makes the following possible in wordpress:
Page A shows number 16
Website visitor visits page B
Page A shows number 15
I would like to have a checkout page (A) that shows a limited offer (number). After purchase the customer is sent to the thank you page (B).This should trigger the number in the checkout page (A) to go down by 1.
Any idea?
Additionally it would be great, if the number reaches 0 and (through php?) if this is reached, the vistor of page A will be redirected to page C.
is there any php function for the child theme or plugin that makes the following possible in wordpress:
Page A shows number 16
Website visitor visits page B
Page A shows number 15
I would like to have a checkout page (A) that shows a limited offer (number). After purchase the customer is sent to the thank you page (B).This should trigger the number in the checkout page (A) to go down by 1.
Any idea?
Additionally it would be great, if the number reaches 0 and (through php?) if this is reached, the vistor of page A will be redirected to page C.
Share Improve this question asked May 6, 2019 at 9:14 AlexAlex 11 Answer
Reset to default 0It depends on what plugin(s) you are using.
Most ecommerce plugins do provide support for inventory. This means that as the shop owner, you can tell the plugin how many of product X you have in stock. Once someone buys an item, the plugin subtracts one, so if you start with 16 of the item and someone buys 1, then the plugin will automatically adjust the inventory to 15. This is better than relying on a pageview - if for example they leave the site to pay on PayPal's website, many visitors don't continue back to the original site and view the confirmation page that you were thinking of using to trigger the reduction of inventory.
As far as redirection, you would also need to create a child theme, and in that child theme's product detail page (often single-product.php
), you would need to set up a check before outputting any content. So, check the inventory of the current product, and if the inventory == 0, redirect to the page of your choice. Else, display the product detail page.