I have created a Cred commerce. Inside this Cred, I have a custom field where I have the post ID of the product to link with the Cred commerce.
But currently, this custom field is numerical and is not recognized by the mecanism inside the Cred (The form specifies the product according to the value of this custom field: ). Nothing appears in the select box.
How can I use a numerical field to define the product ID to link with ?
How do you setup the numerical custom field? How do you put it into CRED form?
The CRED commerce option " The form specifies the product according to the value of this custom field" only work for the custom select field created with Types plugin, for example, you can try this:
1) Make sure you are using the latest version of Types + CRED + CRED commerce plugins
2) Create a custom select field with Types plugin, each option value is a product ID
3) Put it into CRED form, and try again, I have tried it in my localhost, it works fine, see screenshot CRED-commerce1.JPG
Thanks for your return.
What you propose in working fine. That means if I have a select or radio field inmy Cred, it is recognized and can serve to define the product linked to the Cred form.
My issue isthat the field I want to use for defining the product is a numerical field. So, either there is a possibility to use it or I will need to change its format and replace it by a select field for example. I would prefer to keep the numerical field as I need to manage the numerical content of this field in another part of the site.
As you can see, there isn't such a built-in feature within CRED commerce, if you agree, we can take it as a feature request, our developers will evaluate it.
I just tried to change my custom field type (put it in SELECT) and insert this custom field inside my Cred :
<div class="form-group">
<label>Inscription Product ID</label>
[cred_field field='inscription-product-id' post='inscription' value='' urlparam='' select_text='[wpv-post-id]' class='form-control' output='bootstrap']
</div>
The field "inscription-product-id" is a SELECT field and is integrated in the custom fields manages by the postype "inscription".
Even with this, the custom field does not appear in the potential field proposed by the Cred commerce (On the text "Select a custom field" is present.
SO, I changed again the type and replace by a radio field. Then this field is now recognized by Cred commerce, but I cannot affect the [post-id] to this field (when I'm in the frontend, then only "select option 1 is displayed).
So, is there a way to be able to make this :
- place a custom field into Cred
- the field should be recognized by Cred commerce as the ID of the linked product
- the field should be able to be populated by [post-id] inside the Cred
There isn't such a built-in feature within CRED commerce, in your case, it is not needed to use a custom field.
I suggest you try with the CRED commerce filter "cred_commerce_after_add_to_cart" hook to change the product ID in cart, here are detail steps:
1) Add a generic hidden field in your CRED form, to pass the product ID to CRED form:
There you can setup the target product ID to what you want.
2) The CRED commerce option, choose "Always this product, regardless of form inputs:" , choose a default product, any one you want, we will change it in step 3)
Hi Lui
Thanks for your proposais
I'm out of the office currently and back next week-end
I will test all that at that time and come back to you if any issue
Regards
Pat