Skip Navigation

[Resolved] PAID Featured Post Integration or Recommendation

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to provide visitors the ability to create both free and paid posts on the front-end of the site using Forms.

Solution: In the current software this requires two Forms - one for free posts and another for paid posts. A more custom solution that provides both options in a single form will require custom code.

Relevant Documentation:
https://toolset.com/course-lesson/charge-users-for-submitting-content/
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

This support ticket is created 2 years, 10 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#2080337

Don

Tell us what you are trying to do?

howdy, I am looking for a way to have users via front end form have the option to PAY for "Featured Post" status. I know that Toolset has the option to have a pay for access, but that isnt the same.... I want everyone to be able to view, and post, on my site, but want the voluntary option to PAY to make featured available, not limit the ability to view, or post at all, to paid accounts.

I saw in the C&B demo that there were indeed featured posts, but didn't realize until I got under the hood that it was simply a matter of a custom field for "featured" having the box checked...... ie.... no way to charge for it. Sure I could hide the field on the front end form and only check the box from backend as a solution so that nobody could just give their own post featured status for free but it doesn't help integrate a way to get paid for it OR automate the process..... So was hoping that others here had wanted to do the same and had come up with either a solution within toolset OR a 3rd party plugin/integration that works well with toolset that could achieve this. Yes, I have researched before posting here, but oddly enough didnt find anything that seemed appropriate.....

#2080525

Hi, in this case you could set up one Form for publishing unfeatured content, and set up another Form for publishing featured content. In the New Unfeatured Post Form, and any Forms that edit unfeatured posts, you must delete the featured content checkbox completely, so that all posts published or edited by these Forms will be unfeatured. In the New Featured Post Form, include the checkbox field and set it to have a default value of 1, so that the checkbox is checked by default. You could use CSS to hide this field from the front-end if you'd like, or you could remove the field completely and use custom code to set the checkbox field value programmatically with our cred_save_data API: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data. I can share examples of CSS or the PHP API if you'd like to take either of those approaches.

You'll use Forms Commerce to connect the New Featured Post Form to a specific Product you have set up in WooCommerce, to charge Users for posting featured content, as described in the Forms Commerce documentation: https://toolset.com/course-lesson/charge-users-for-submitting-content/

You can configure the commerce form to publish the featured post when payment is completed. Will this work for your situation, or do you have other requirements to consider? Please elaborate and I can help find a better solution.

#2080627

Don

thanks for the tip and walk through..... to be honest i already HAD looked at the forms commerce option but, at least from the initial read on it, it sounded like it was specifically FOR woocommerce sites, not that it jsut "uses" woocommerce on the backend to handle the payment flow. Will look into it more thanks. But to clarify, having mulled your idea over regarding two SEPARATE forms where they decide in advance whether to be featured or not, based on the read in this section: https://toolset.com/course-lesson/charge-users-for-submitting-content/#2-connecting-products-to-forms

it kind of gave me the impression that if i had the product (ie featured status, bold status or whatever) and selected the option "the form specifies the product according to the value of this custom field" then here: https://toolset.com/course-lesson/charge-users-for-submitting-content/#2-1-product-to-buy

i could offer a variety of custom field options that correspond to different "products" (featured, bold, etc).... and that would basically do what im after..... without having to do two separate fields. or am i misunderstanding?

Also, it states we can setup the custom field as a "radio button" for our various product options.... but that means they can only select ONE product right? Or is that possible to do as checkboxes and allow someone to select featured AND bold AND whatever else? that would be perfect. But, even if not, if this option really works as i got the impression (again, thanks for pointing me that way as an option for a non-woocommerce site, i had basically written it off as not applicable since my site is a directory and not a store), then even if we can only allow users to select one product or the other that would be fine, and better than two separate forms and the user having to decide "in advance" whether to post a featured ad or not.....

#2080869

i could offer a variety of custom field options that correspond to different "products" (featured, bold, etc).... and that would basically do what im after..... without having to do two separate fields. or am i misunderstanding?
That is definitely possible. I was under the impression that there are two use cases for publishing posts:
- Unfeatured free post
- Featured paid post
In this scenario it does not make sense to use the same Form to publish a free post as the Form to publish a paid post, since there would be no easy way to bypass purchasing a product to publish a post. A User trying to submit a free post would be forced to purchase something in order to submit the Form and publish their post. I've seen other Users create "free" Products for this scenario, but the workflow is a bit clunky because it requires completing an order in the WooCommerce flow.

If all the options for publishing require payment of some amount, then one Form with the option to choose different products corresponding to different post enhancements makes perfect sense. It will most likely require custom code to set the custom fields corresponding to each desired feature programmatically in the new post, depending on the product purchased. If a free publishing option is desired, I think two Forms will be easier to implement from a technical perspective and result in a better overall experience for your Users.

Also, it states we can setup the custom field as a "radio button" for our various product options.... but that means they can only select ONE product right? Or is that possible to do as checkboxes and allow someone to select featured AND bold AND whatever else? that would be perfect.
Checkboxes for multiple selections are not supported in the built-in workflow, just a radio input that allows one selection from a predefined group of options. A separate product for each possible combination of features is probably the best way to handle these combination purchases in the built-in system. Otherwise, a more complex customization with the Forms Commerce API is in order:
https://toolset.com/documentation/programmer-reference/cred-commerce-api/
That would allow you to programmatically determine which product should be placed in the User's cart based on the features they select in some generic fields, and then which features are added to the post they publish based on those selections.

#2080887

Don

thanks again for the thorough and thoughtful answer. Crumb, i was hoping that offering a "free"option with no cost would circumvent the woocommerce flow necessity.... didnt stop to think that in the example in the documentation a "normal" listing for them jsut meant a "normal cost" listing rather than free as i would intend.
"A User trying to submit a free post would be forced to purchase something in order to submit the Form and publish their post. I've seen other Users create "free" Products for this scenario, but the workflow is a bit clunky because it requires completing an order in the WooCommerce flow. ".... as you well put it is the hook, or wall in my way. I definitely want "free" to be an easy and default option, but with an easy option to pay for featured..... ideally not at the beginning, since for many is something they are unsure of until they have finished putting their spiffy listing together and, having put all the effort into it, right before submitting see the tempting option to pay just a little to get their masterpiece on top of the garbage. And having two SEPARATE forms means there is no easy changing of their mind, they would basically have to start over completely. I hope that this is being considered for inclusion at some point, i think regardless of what the site is about if an admin is allowing front end content creation they would probably like at least the easy option of charging for listing promotion/enhancements.

Regarding the radio buttons, thanks for clarifying. sure is easy enough to workaround by making "packages" of enhancement options so they can pick a single level with various components included rather than pick and choose individually.... so im not griping and can make it work..... but i think that given woocommerce is geared toward product purchases, and ideally multiple at once, that there really shouldnt be any hurdle on that end preventing the selection of multiple products (upgrades) at once..... but i understand it on the toolset side of things it is more complicated than someone like me with limited coding skills would see it....

#2082041

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Don,

Christian is currently out sick today but should be back tomorrow to continue assisting.

You should get a response from him or another supporter tomorrow should he be out again tomorrow sick.

Thank you for your continued patience on this one.

Thanks,
Shane

#2083423

I hope that this is being considered for inclusion at some point, i think regardless of what the site is about if an admin is allowing front end content creation they would probably like at least the easy option of charging for listing promotion/enhancements.
I think it's a reasonable scenario, so I can submit a feature request to the developers for inclusion in a future release. Realistically feature requests take a considerable amount of time to be implemented, so if they decide to implement this change, I would not expect it to be ready for a project that you have with a launch date in the near future.

If you consider this workflow vital to your project, you might consider working with an independent contractor to come up with a custom code solution. We have a list of contractors available here: https://toolset.com/contractors/
And for smaller projects like this one you can check here as well: https://codeable.io/developers/toolset/

#2083515

Don

My issue is resolved now. Thank you!

#2083651

Don

well, i set up a "free" product to see if this code i found on stackoverflow (You can use the following to disable checkout payment when there is only free products in cart:)

add_filter( 'woocommerce_cart_needs_payment', 'filter_cart_needs_payment_callback', 100, 2 );
function filter_cart_needs_payment_callback( $needs_payment, $cart ) {
return $cart->subtotal > 0 ? $needs_payment : false;
}

but it still went to the checkout page with a $0.00 total..... i am wondering if this could be issue could be an issue of the combined woocommerce and toolset commerce flows and, if so, whether this code can be modified to make it redirect directly to the post page if the cart subtotal is 0....

#2083693

but it still went to the checkout page with a $0.00 total..... i am wondering if this could be issue could be an issue of the combined woocommerce and toolset commerce flows and, if so, whether this code can be modified to make it redirect directly to the post page if the cart subtotal is 0....
Right, you're describing the clunky workflow I mentioned earlier when using a free product. In order to redirect directly to the post when the Commerce Form is submitted, the post must be published immediately when the Form is submitted. Well, you can use the Form's redirection settings to redirect to the post, and use the Form's post status settings to set the post to be published automatically, but then you've broken the functionality of creating a paid post in the same Form. Users would be able to publish a paid post without making a purchase, because there is no built-in way to use different redirect settings and post statuses based on the product selected. So I don't think you're going to be able to solve the problem completely just by redirecting to the post, it's a bit more complicated than that.

There's nothing in the code snippet you shared that will help you adjust the redirection settings in the Form - those are all managed in the Form editor page.

In a typical Commerce Form, you'll use the form options to create the post in Draft or Pending Review status until the payment is complete. Otherwise, a User can publish a featured post without submitting payment for their enhanced post. You normally use the redirection settings in the Form editor to send the User to the cart or checkout page when the form is submitted, because usually in the paid workflow this is the most intuitive way to indicate that the User must complete the order process to see their post published. Otherwise, they may not realize a product has been added to their cart, and they may not know to go to the checkout page to finish the process.

So that's the clunky part that is not easily overcome with the built-in features of Commerce Forms. We have some PHP APIs available for Commerce Forms if you're looking for a custom solution with PHP:
https://toolset.com/documentation/programmer-reference/cred-commerce-api/

Specifically, the cred_commerce_form_action API can be used to manipulate the redirect settings you choose in the Form editor:
https://toolset.com/documentation/programmer-reference/cred-commerce-api/#cred_commerce_form_action
A custom solution might use this API to inspect the product selected in the Form. If it was a free product, remove that product from the User's cart since there is no need to go through the WC Order flow in this case. Set the new post status to 'publish' programmatically, then redirect to it. That would maintain the paid submission workflow and functionality for enhanced posts, and automatically publish free posts.

#2083865

Don

thanks again, yeah i expected to see the clunky workflow you originally described since the toolset form would, as expected and desired, send each and every form submit to woocommerce checkout..... i agree that is how it SHOULD be, i had just hoped that, once in woocommerce, this piece of code would trigger woocommerce to recognize the checkout amount is $0.00 so checkout can be immediately pushed through without displaying the checkout page really, and would go to the next step "as if" payment had been completed. But, it didnt. so i guess i will just stick with your original suggestion to offer separate forms (i could do both forms on the same page though right in separate tabs right and they "pick" the form to sue based on the active tab? That could work, is at least better than two separate forms on two separate pages.... i might even look into "sharing" the inputed field data between the two forms so that a user could, theoretically, switch to the other tab (choose featured after all or the opposite and change their mind on paying for featured after entering it all in and wanting to submit as free listing) and the already entered data would be pre-populated. not sure if will work since the fields are identical, just located in different forms. but if a way to do it could be a good solution..... thanks again for your insight and recommendations!

#2084025

i could do both forms on the same page though right in separate tabs right and they "pick" the form to sue based on the active tab? That could work, is at least better than two separate forms on two separate pages.
Sure, you could present multiple Forms on the same page and allow the User to pick the Form by switching tabs or by showing/hiding different Forms with JavaScript somehow. I don't foresee any problem there. If you're comfortable writing JavaScript, you could probably share data across both Forms as the User enters their post information. You can use Toolset's enqueued jQuery in the namespace 'jQuery' instead of the customary '$' namespace, if you'd like.

#2084029

Don

thanks for the additional clarification and suggestions!

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