Skip Navigation

[Closed] Set up Flexible Product Selection in CRED Commerce

This support ticket is created 8 years, 4 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Tagged: 

This topic contains 25 replies, has 4 voices.

Last updated by yuri.s 8 years, 2 months ago.

Assisted by: yuri.s.

Author
Posts
#351543

In this guide: https://toolset.com/documentation/user-guides/using-cred-commerce-to-add-payments-to-forms/ it says:

"Forms can also require different payment amounts. For example, if you want to offer several ad options (normal, bold, super-featured), you can set this up using the ‘The form specifies the product according to the value of this custom field’ option.

In this case, you should create several products and a custom field who’s value corresponds with the item IDs. A select or radio input would be great for this purpose."

Exactly where do I set that custom field? On which post type?

I was thinking of passing the product ID as a post parameter to the cred form and inserting it in a hidden field with a shortcode. But does that work out with CRED Commerce?

#351628

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

1)
You can either select Product CPT or even you can assign these custom fields created using types to any CPT from:
=> Types => Custom fields => Add/Edit custom fields group => select CPT to which you want to assign custom field group

More information:
=> https://toolset.com/documentation/user-guides/using-custom-fields/
[Section "Controlling Where Custom Field Groups Display"]

2)
=> https://toolset.com/documentation/user-guides/using-cred-commerce-to-add-payments-to-forms/
[ Section: "2. Connecting Products to Forms"]

From were you can control the settings.
=> hidden link

As you can see on above image there is a option setting "The form specifies the product according to the value of this custom field" where you will be able to select the created custom fields.

What I suggest is that you should create a test site on discover-wp.com with our available "classifieds" sample sites and play with it for better understanding:
=> http://discover-wp.com/site-types/classifieds/

#351637

I do know how to add custom fields to CPTs, 1), as I've worked with Toolset for a long time now and I have already been to 2) in order to set it up.

I'm asking specifically where I should add the custom field, that will work with CRED Commerce in order to pass a specific product ID? It's not clear to me from the guide or the interface.

#351644

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

cred-product.jpg

1)
You should try to add generic field and assign product ID as a value to this field.
Or
You may also try a HTML input:

<input name="my_product_id" value="YOUR-PRODUCT-ID"  />

2)
Then, With your CRED form which you are using, Edit CRED form and at section "CRED Commerce" select the option "The form specifies the product according to the value of this custom field" and it will populate the field to which you have passed the product ID.

Please find attached screenshot.

#352234

I managed to create a generic radio field, which gets its value from a shortcode:

[cred_generic_field field="evi-product-id" type="radio" class="evi-product-id" urlparam=""]
{
"required":0,
"validate_format":0,
"persist":1,
"default":[],
"options":[ [evi-register-productid] ]
}
[/cred_generic_field]

The shortcode is outputting JSON like this:

{"value":2338}

Here is the radio HTML source being created:

<div class="js-wpt-field-items js-wpt-repetitive wpt-repetitive" data-initial-conditional="" data-item_name="radios-evi-product-id"><ul class="wpt-form-set wpt-form-set-radios wpt-form-set-radios-evi-product-id">
<li class="wpt-form-item wpt-form-item-radio radio-">
<input type="radio" id="form-173565439" name="evi-product-id" value="2338" class="wpt-form-radio form-radio radio" data-wpt-type="radio" data-wpt-id="cred_form_313_1_form-173565439" data-wpt-name="evi-product-id" /></li>
</ul>
</div>

The number is a WooCommerce product ID.

I have chosen this on the CRED form:

"Clear the cart and include only the selected product "

"After payment completes, make the client the author of the post"

"Choose what to do after visitors submit this form: Go to Checkout page"

Now, when I send the form and should go to the WooCommerce Chekout page, instead I get to the Cart page. As a logged-out user I just get "Your cart is currently empty." If I'm logged in I also get "Sorry, this product cannot be purchased."

From the last sentence I investigated and found out that the function is_purchasable in woocommerce/includes/abstracts/abstract-wc-product.php returns false.
In there (the get_price part of is_purchasable) I extracted $this->id and got the ID of the post being created by the form and not the product ID, which I'm trying to pass from CRED Commerce to WooCommerce.

So what to do now?

#352547

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

1)
is_purchasable returns true when the product has no stock. Could you please check the stock inventory maybe its on and possibly no stock available with product.

2)
If your issue still persist:

Can we have a working demo site where we can see this?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#352894

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've escalated your ticket to our next level support. Please be patient, wait for a reply from them and they will get in touch with you as soon as possible.

#353190

2nd tier: Will you have time to look at this issue soon?

Regards,
Jakob

#353845

Hello,

I'm Adriano, Toolset support lead. Please let me see the full code of the shortcode [evidensia-register-productid]. Are you using return or echo?

#353953

Here:

add_shortcode( "evidensia-register-productid", "evidensia_register_product_id" );
function evidensia_register_product_id() {
	$product_id = $_POST['product_id'];
	$product_id_json = "{\"value\":$product_id}";
print_r($product_id_json);
	return $product_id_json;
}

I use the print_r to see the value. Maybe would be better with error_log().

#354123

Have you fixed this? I see now this in the front-end: {"value":2304}

#354131

No, I haven't fixed it. The problem is still what is mentioned in the last part of this post:

https://toolset.com/forums/topic/set-up-flexible-product-selection-in-cred-commerce/#post-352234

#357136

Hi Jakob, I'll helping out Adriano on this issue and looking into it right now.

I'll let you know as soon as I have any updates.

Regards,
Yuri.

#357636

Thanks, Yuri. Hoping for a solution.

#360454

Hi Jakob, our debugging of this issue is taking a bit more time than we anticipated but we are working hard on this.

As soon as I have an update I'll let you know.

Regards,
Yuri.

The topic ‘[Closed] Set up Flexible Product Selection in CRED Commerce’ is closed to new replies.