Sauter la navigation

[Résolu] How to extend the forms woocomm plugin to prepay for single and packs of post

This support ticket is created Il y a 4 années et 11 mois. 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)

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par MargeP6083 Il y a 4 années et 11 mois.

Assisté par: Luo Yang.

Auteur
Publications
#1463179

Tell us what you are trying to do?
I want users to be able to pre-pay for post submission, then be able to post the number of posts they buy. For instance 1, 5, 10, 25 post packages.

Is there any documentation that you are following?
https://toolset.com/documentation/user-guides/front-end-forms/using-cred-commerce-to-add-payments-to-forms/

Is there a similar example that we can see?
I'm having trouble locating this example. It works like a job board, but to buy the job postings in advance.

What is the link to your site? lien caché

Do you have recommendations on instructions?

#1463463

Hello,

There isn't such kind of built-in feature within Toolset Forms plugin, as you see in the document you mentioned above, it can charge the user once he create a new post.

In your case, it needs custom codes, for example:
1) Create a new numeric user field "post packages"
2) Setup some Woocommerce products for users to purchase:
- 1 post package
- 5 post packages
- 10 post packages
...
3) After user buy one of above product, for example "5 post packages", and complete the Woocommerce order, use Woocommerce built-in action hook "woocommerce_order_status_completed" to trigger a PHP function:
lien caché
4) in this PHP function update user field "post packages" value + 5
https://developer.wordpress.org/reference/functions/update_user_meta/
5) Create a post view
- query posts
- filter by post's author same as current logged in user:
https://toolset.com/documentation/user-guides/views/filtering-views-query-by-author/
- in section "Loop Editor", you can get total post found count with shortcode [wpv-found-count]
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-found-count
get current user's "post packages" field value with Types shortcode [types usermeta='post-packages' format='FIELD_VALUE' current_user='true'][/types]
https://toolset.com/documentation/customizing-sites-using-php/functions/#numeric
Use shortcode [wpv-conditional] to compare above two shortcodes, if "post packages" field value is higher, then display below creating post form
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-conditional
6) Create a post form for creating new post, after user submit the form and new post created

For your reference.

#1464047

This is incredibly helpful! I had trouble thinking this through. Woocommerce has a trigger add-on that might work here. I will give this a go and contact a contractor if I can't complete this.

Very grateful for your help!

My issue is resolved now. Thank you!