Want to add custom option from the frontend of magento
I want to add a button on product view page. By clicking on th开发者_开发知识库at button, there will appear two text box fields which are custom options. When I open that product from the backend, I can find that there are custom options which I added, but I need to view it in the frontend by clicking the button only.
First of all, Products are added by the administrator, and are fully controller also by the Administrator. Only thing is that you (as a customer) can only see the custom options which are available for a particular product (and as provided by the admin).
In your particular case, go to the proper Admin page (Edit / Add a new Product and go to its "Custom Options" tab). Now provide options for two text fields, with two different labels, and then save that product. Now if you go to the front-end to view that product, you will find the product details, along with the two custom options added from the admin section.
Also if you want to add a button in the front-end of each product view page, which when clicked will show the custom options, then you need to create a button & write a JavaScript for opening the container of the Custom Options.
Hope it helps.
Edit:-
First find out the full HTML section of the Custom Options, or in other words, the HTML container of the Custom Options in the Product view page. Provide a unique "id
" to the container "DIV
" element and make that element hidden. Also provide the HTML button anywhere in the view page, and call the unique ID of the "DIV
" element in the "onclick
" event of the button. A simple code snippet will be like:-
<div id="any_unique_id" style="display: none;">
// Whole Custom Options
</div>
<button onclick="$('any_unique_id').show();">Click here to view the Custom Options</button>
checkout Knowledge Craving 2nd part's answer
精彩评论