I'm working with an old add-on (one Burt wrote many years ago) in an older version of Phoenix (please don't judge), that, while viewing an item in the product_info.php page, allows a customer to enter an email address to be notified when an item is back in stock. The add-on uses a form (within the product_info form) to collect and record the email address. This form-within-a form is creating a problem.
1) As written, when the customer submits their address, product_info.php either:
a) ignores saving the email address, and if there are no attributes, records the submission as 'add to cart', or
b) ignores saving the email address, and prompts for any needed attribute.
In both cases, the email address is not recorded.
2) If I delete the opening <form> code in product_info.php (but leave the closing <form>), the customer's address submission is recorded. But, nothing is recorded when the 'Add to Cart' button is clicked.
3) If I then add an opening <form> tag to the beginning of the 'buy_button' code, when the 'Add to Cart' button is clicked, the item is added to the cart IF there are no item attributes. But if there ARE attributes to select, than nothing is added to cart.
4) If I then add another opening <form> tag to the beginning of the 'options_attributes' code, clicking the 'Add to Cart' button adds the item to the cart (both with and without attributes).
( If I leave the opening <form> tag to the beginning of the 'options_attributes' code, but remove it from the beginning of the 'buy_button' code, clicking the 'Add to Cart' button ONLY works with items with attributes (that have been correctly selected), and NOT for items without attributes.)
And, if the customer also selected to be notified (don't know why, since the item is in stock, but checking anyway), the email address is also recorded.
So, while this (#4) 'works' the way I want, the generated HTML code has lots of 'red flags' ... a form-within-a form, a stray end <form> tag, etc.
So, how can one have a form-within-a-form that works, and still generate clean code?
(I have considered putting the email address 'form' in a pop-up modal, and moving the actual code down into the footer (I've done that before))
I'm sure that there probably are other add-ons that do this, but I'm also using this as a learning experience
So, any ideas of how to deal with a form-within-a-form (short of upgrading to a newer version of Phoenix)?
TIA!
Malcolm