Skip Navigation

[Resolved] Upgrading listing to paid, without creating a new listing

This support ticket is created 7 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 7 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#471553

I am building a directory site. What I would like to be able to do is the following:

1. A user registers.
2. A user chooses between a free and a paid listing.
3. After the listing has been placed, it should be possible to upgrade the existing listing from free to paid - without deleting the old listing and creating a new one.
4. The payment should be handled with Woocommerce.
5. After the period that has been paid for expires, the listing should revert from a paid to free listing

Number 1 and 2 are no problem, but I struggle at number 3 to 5.

The fields the user fills in are the same for for a free and a paid listing. But while the free listing shows a limited number of these fields, the paid listing shows all of the fields. Also, there should be an additional CRED form be displayed within the paid listing that should not be visible on the free listing.

All solutions I have found, are based on a free and paid listing from the beginning and do not have the possibility to upgrade an existing listing, without deleting the old and starting all over with the new one.

What is the correct way to build this flow on my site?

Thank you for your help!

#471723

Dear Jack,

It needs some custom codes.
For example, you are using a custom field to define the paid or free listing post:
there is a custom field "free-or-paid" in each listing post

3) After the listing has been placed, it should be possible to upgrade the existing listing from free to paid - without deleting the old listing and creating a new one.
You can setup a CRED form to edit the "listing" post, and attach it with a Woocommerce product, after user complete the Woocommerce order, use CRED commerce action hook "cred_commerce_after_order_completed" to update the "listing" post to paid post
https://toolset.com/documentation/user-guides/cred-commerce-api/
cred_commerce_after_order_completed
Action to be executed after WooCommerce order status is set to completed

4) The payment should be handled with Woocommerce
Yes, see above 3)

5) After the period that has been paid for expires, the listing should revert from a paid to free listing
After the post is expired, then use CRED action hook cred_post_expiration_custom_actions to update the post as free listing post:
https://toolset.com/documentation/user-guides/automatic-post-expiration/
section "What happens when posts expire"
When posts expire, their status is set to what you have selected via the GUI. You can also set post meta values by using the ‘cred_post_expiration_custom_actions’ filter.

#472119

Thank you for your response. I followed your steps. It took some fiddling with the code, but I was able to get it working. I have one question left, regarding the expiration.

-----------------------------------
5) After the period that has been paid for expires, the listing should revert from a paid to free listing
After the post is expired, then use CRED action hook cred_post_expiration_custom_actions to update the post as free listing post:
https://toolset.com/documentation/user-guides/automatic-post-expiration/
section "What happens when posts expire"
When posts expire, their status is set to what you have selected via the GUI. You can also set post meta values by using the ‘cred_post_expiration_custom_actions’ filter.
-----------------------------------

The post itself does not expire. The post already exists before the payment is done and it will continue to exist after the payment period has passed. Only the field free-or-premium should change. Can I still use the action hook cred_post_expiration_custom_actions in this case or should I handle this differently?

Thank you!

#472497

Q6) Can I still use the action hook cred_post_expiration_custom_actions in this case or should I handle this differently?
Yes, you can setup your CRED form, option "After expiration change the status of the post to:" choose "Keep original status"
, but in action hook cred_post_expiration_custom_actions to update the field "free-or-premium" value.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.