Announcement

Collapse
No announcement yet.

Assign Quantity to a variable

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Assign Quantity to a variable

    Hi,

    I am trying to assign a product quantity to a new variable so I can carry it to another product screen.

    Here is what I was trying to do:

    Customer adds product CAM1001 to the cart.

    Next screen is an option to add another product that compliments this one - they click on the option in this form:

    <form method="POST" action="&mvt:global:sessionurl;">
    <input type="hidden" name="Store_code" value="&mvt:store:code;">
    <input type="hidden" name="Screen" value="PROD">
    <input type="hidden" name="Product_Code" value="ENV_9_CAM">
    <input type="hidden" name="Action" value="post">
    <input type="hidden" name="quantity" value="&mvt:product:quantity;">
    <input type="image" src="../images/but_option1.gif">
    </form>

    On the next product screen I need to fill the quantity field for the new product for the customer so they don't have to fill it in. I am ok with them being able to change it, I just wanted to populate it for them.
    Qty: <INPUT TYPE="text" NAME="quantity" VALUE="&mvt:product:quantity;">

    When I use &mvt:product:quantity; it is a 0 so I think I need to assign &mvt:product:quantity; to a variable in the above form?

    Thanks,
    Mike

    #2
    You probably want to use &mvte:global:quantity; instead of &mvt:product:quantity; - however it's impossible to know for sure without knowing the name of the quantity field on the initial form.
    M.A.D.* since 1997

    http://www.scotsscripts.com

    *miva application developers

    Comment


      #3
      Thank you, that worked for me!

      Comment


        #4
        One more question on this one. Can I add a variable in the form below that will carry to the following product page? I want to write a conditional on the next page that checks to see if the variable is 1.

        So let's say the variable name is MERGE and it needs to be equal to 1

        I tried this in the form below and it isn't working for me:

        <mvt:assign name="g.MERGE" value="1" />

        Then had this on the product page to test it:
        <mvt:if expr="'g.MERGE' EQ '1'">
        This worked
        <mvt:else>
        Nope
        </mvt:if>



        This is the form:

        <form method="POST" action="&mvt:global:sessionurl;">
        <input type="hidden" name="Store_code" value="&mvt:store:code;">
        <input type="hidden" name="Screen" value="PROD">
        <input type="hidden" name="Product_Code" value="ENV_9_CAM">
        <input type="hidden" name="Action" value="post">
        <input type="hidden" name="quantity" value="&mvte:global:quantity;">
        <mvt:assign name="g.MERGE" value="1" />
        <input type="image" src="../images/but_option1.gif">
        </form>
        Last edited by mstella1; 01-28-23, 11:26 AM.

        Comment


          #5
          Yes. Anything added inside a <form> tag with input="hidden" becomes what is called a CGI variable available as g.value of name on the subsequent page.

          so, input type="hidden" name="myVariable" value="20">

          becomes g.myVariable containing the value of 20 on the next page.

          this is the same as when you add myVariable=20 to a URL. for example www.domain.com/some-url.html?myVariable=20 is the same as the above. (caution though, CGI variables passed via a URL are 'encoded' so my variable would be my%20variable unless you decode it first.
          Bruce Golub
          Phosphor Media - "Your Success is our Business"

          Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
          phosphormedia.com

          Comment


            #6
            Perfect! I was able to do this in the URL and that worked. I've never tried it in a form like that before and was drawing a blank on a good way to accomplish such a simple task :) Saved me from having to make 10 new product pages.

            <form method="POST" action="&mvt:global:sessionurl;&MERGE=1">

            Thanks again as always!

            Comment

            Working...
            X