Issue
Is there a way to add price if the client add the custom text (the one inside the Options section when you add the product) in a product? or have I to add it by product combinations (adding a lot of combinations)?
With the input radio I can't control what the user will do and I can't set it as "required" because it must be a free choice.
{block name='product_customization_form'}
<form method="post" action="{$product.url}" enctype="multipart/form-data">
<ul class="clearfix">
{foreach from=$customizations.fields item="field"}
<li class="product-customization-item">
<label> {$field.label}</label>
{if $field.type == 'text'}
<textarea placeholder="{l s='Your message here' d='Shop.Forms.Help'}" class="product-message" maxlength="250" {if $field.required} required {/if} name="{$field.input_name}"></textarea>
<small class="float-xs-right">{l s='250 char. max' d='Shop.Forms.Help'}</small>
{if $field.text !== ''}
<h6 class="customization-message">{l s='Your customization:' d='Shop.Theme.Catalog'}
<label>{$field.text}</label>
</h6>
{/if}
</li>
{/foreach}
</ul>
<div class="clearfix">
<button class="btn btn-primary float-xs-right" type="submit" name="submitCustomizedData">{l s='Save Customization' d='Shop.Theme.Actions'}</button>
</div>
</form>
{/block}
Solution
The best way to achieve this would be to have two product combinations:
- With custom text (+$0)
- Without custom text (+$1.00)
Next, add some custom Javascript code to your product page (the proper way would be via a module) that would do the following:
- Check if the customization textarea element is present on the page
- Check if it is empty or not
- If not, force the combination ID to the right ID (the "with customization" version)
That's it.
That way, the buyer won't have to select any option, they just have to fill a custom text if they would like to and the price will adjust automatically in their shopping cart.
I hope this helps!
Answered By - Bruno Leveque Answer Checked By - Robin (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.