2

I need to extend Magento 2.1 to allow products to be added to cart by the square foot (flooring). However the products are sold by the carton. Therefore I need an extension that will allow the visitor to provide square footage, while the site converts up to the next full carton. Of course, each product that is sold this way would have a SFperCarton attribute set to a numeric value greater than zero.

I have a lot of experience as a software developer, however I have almost no experience with PHP. I am looking for community's opinion on the relative difficulty for creating this extension for Magento 2.1.

Also, are there any good resources that anyone knows of to get me started? Any help would be greatly appreciated.

2

One possible way would be to first add the SFperCarton attribute to the product entity (tutorial here: https://www.atwix.com/magento/adding-attribute-programatically-magento2/).

Then, using this tutorial: http://inchoo.net/magento-2/add-qty-increment-buttons-to-product-page/ as a starting point, you could modify the addtocart.phtml template to check if the product has 'SFperCarton' set and if so insert another input element that allows you to enter the square footage. Some javascript then converts that number to cartons, which is then entered in the actual 'Qty' field. I don't know if that's exactly what you want, but it would be a relatively quick and easy way to go about it.

  • This is exactly what I was looking for. Thank you! – m-albert Aug 23 '16 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.