Ask About Product - Alekseon/magento2-widget-forms GitHub Wiki
- "Ask About Product" form on all product pages.
- Email input displayed only for guests
- Connect currently viewed product with question
|
YouTube video presentation: https://www.youtube.com/watch?v=0JoRBGZZMK4
To create form go to Content -> Elements -> Manage Custom Forms, and add New Form.
In General tab set form properties:
- Title - lets name it "Ask About Product"
- Can use as frontend widget - set to yes, we want to use this form on frontend.
|
Add fields in Form Fields tab. We need at least 3 fields:
- Product SKU - set is as Text Field type and required.
- Email - set is as Text Field type and required.
- Message - set is as Text Area type and required.
|
To place form on product page, You can use native Mangeto widgets mechanism. Go to Content -> Elements -> Widgets and Add Widget
- As type select [Alekseon] Widget Form
- Select Your theme
- Continue
|
Setup storefront properties, add Layout Update to All Product Types. Select container which You want, for example "Product View Extra Hint" can be good for display form.
|
Widget Options tab
- Select Ask about product form
- Hide form title set to No
- Hide form description set to No
|
Save widget.
Now "Ask about product" form is visible on product page.
(You may need to refresh the cache)
|
Form is displayed on product page, customer is asking about product from this page. We don't want to display "Product SKU" field. We can do it by changes in "Product SKU" field configuration.
- Set Input Block Type as Hidden
- Open field Advanced Settings
- Set Default Value to Current Product SKU
|
|
We want do display this field only for guests. For logged in customer we want use email address from his account.
- Set Input Block Type as Hidden If Has Default Value
- Open field Advanced Settings
- Set Input Validator to Email Address
- Set Default Value to Customer Email
|
|
As result we have Ask about product on all product pages. Email address input is visible only for guests.
|
In admin panel we can see product sku, customer address and question of submitted forms.
|
Enjoy!