Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    red flag Separate action on product information form

    I am looking for a way to have two actions on the product information page form. One action for submitting the product to the cart as normal with zen cart. The other action needs to call a script to check.

    Currently the form in zen cart on the products information page looks similar to this:

    <form name="cart_quantity" action="https://mydomainname.com/index.php?main_page=product_info&amp;cPath=383&amp;products_id=23464&amp;action= add_product" method="post" enctype="multipart/form-data">

    This form adds the products to the cart when submitted.

    I have another custom PHP script I am wanting to call within the page.

    The product has a text field attribute where the customer can enter details for a domain name. But I need a button next to the attribute field so that a customer can check availability. I already have a script to do this and as an example, without being a part of zen cart a form for checking availability would look like this:

    <form name="cwhoisform" id="cwhoisform" action="cwhoisform.php" method="POST" target="_blank">
    Domain
    <input type="text" name="domain">
    <input type="submit" value="Check">
    </form>

    What I need is to somehow combine the two forms so that a user can check availability before they submit to the cart. And once they have confirmed availability they can then add to the cart.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  2. #2
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    Default Re: Separate action on product information form

    Another option would be to build in the domain name lookup form as a different form, say just above the product information form so customers could fill out a domain name look up field and if the domain name is available, have it populate the attribute text field. Is this possible?
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  3. #3
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Separate action on product information form

    Couple of options come to mind:
    Currently trying to use the form method, as presented there is form posting information that is missing, namely the hidden field of securityToken that is generated when using the zen cart built in: zen_draw_form function found in includes/functions/html_output.php

    Another is to modify the processing code when the action of add_product is identified. One place in which this can be done is within the init_cart_handler.php file found in includes/init_includes

    Yet another software approach is to add something to includes/extra_cart_actions to process the applicable request before actually adding to the cart. (I suggest this part of the process as it will withstand upgrading by not being overwritten, though must also be carried over and reviewed for applicability as necessary.)

    Another is to use ajax to pull the data when selections are made; however, this only works when/if javascript is enabled and therefore would not offer the information/check if disabled locally by the visitor.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #4
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    red flag Re: Separate action on product information form

    Quote Originally Posted by mc12345678 View Post
    Couple of options come to mind:
    Currently trying to use the form method, as presented there is form posting information that is missing, namely the hidden field of securityToken that is generated when using the zen cart built in: zen_draw_form function found in includes/functions/html_output.php

    Another is to modify the processing code when the action of add_product is identified. One place in which this can be done is within the init_cart_handler.php file found in includes/init_includes

    Yet another software approach is to add something to includes/extra_cart_actions to process the applicable request before actually adding to the cart. (I suggest this part of the process as it will withstand upgrading by not being overwritten, though must also be carried over and reviewed for applicability as necessary.)

    Another is to use ajax to pull the data when selections are made; however, this only works when/if javascript is enabled and therefore would not offer the information/check if disabled locally by the visitor.
    Ok so are you saying add cwhoisform.php into includes/extra_cart_actions?

    So if that is the case how would I call the script to check availability?
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  5. #5
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,472
    Plugin Contributions
    88

    Default Re: Separate action on product information form

    Quote Originally Posted by Nick1973 View Post
    Ok so are you saying add cwhoisform.php into includes/extra_cart_actions?

    So if that is the case how would I call the script to check availability?
    The scripts in the /extra_cart_actions are called one-by-one each time a page-load with a cart-action (e.g. action=add_product) is processed. The Limit Downloadable Products plugin makes use of this 'override'; perhaps you could use that to give you ideas.

  6. #6
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    Default Re: Separate action on product information form

    Quote Originally Posted by lat9 View Post
    The scripts in the /extra_cart_actions are called one-by-one each time a page-load with a cart-action (e.g. action=add_product) is processed. The Limit Downloadable Products plugin makes use of this 'override'; perhaps you could use that to give you ideas.
    Right so if I add cwhoisform.php into includes/extra_cart_actions are you saying it will just load that script?
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  7. #7
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Separate action on product information form

    Quote Originally Posted by Nick1973 View Post
    Right so if I add cwhoisform.php into includes/extra_cart_actions are you saying it will just load that script?
    It will attempt to process the contents of that script, yes.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  8. #8
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    Default Re: Separate action on product information form

    Quote Originally Posted by mc12345678 View Post
    It will attempt to process the contents of that script, yes.
    I've put the script inside includes/extra_cart_actions

    ok so I have my attribute field <input type="text" name="id[txt_19]" size="32" maxlength="32" value="" id="attrib-19-0"> which needs a submit button so they can click and it checks if the domain name is registered or not.

    So how would I call the script inside the product info page to make it do what I want?
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  9. #9
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    red flag Re: Separate action on product information form

    I've attached a copy of CWHOIS here cwhois-zip.zip
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  10. #10
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Separate action on product information form

    HTML doesn't let you nest 2 forms inside one another.

    Perhaps you want to use javascript to attach a button the id of that element so you can use that for repositioning it on-screen, where clicking the button does an ajax lookup and provides in-page feedback, before they even submit the product for add-to-cart.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Customizing Contact Us Form, the action="" param,
    By tcarden in forum General Questions
    Replies: 2
    Last Post: 27 Dec 2012, 08:32 PM
  2. Form action posting back to tpl_checkout_success
    By glennnz in forum General Questions
    Replies: 4
    Last Post: 26 Aug 2008, 08:34 PM
  3. where do i have to write code to get response from form action url
    By krush in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 31 Mar 2008, 05:12 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR