Announcement

Collapse
No announcement yet.

How do I code a button with custom product field to be used as a order product link

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

    How do I code a button with custom product field to be used as a order product link

    I have created this test page http://www.invinciblemusic.com/test3. It has a button titled "Add Album MP3" to cart.

    Hard coding the button it looks like this:

    <div id="prodadd"><a href="http://www.invinciblemusic.com/mm5/merchant.mvc?Screen=BASK&Store_Code=IM&Product_Cod e=DLM-blue-star&Attributes=Yes&Quantity=1&Action=ADPR "><input type="image" src="graphics/en-US/new/add-mp3-yoga-music-to-cart.jpg" border="0" /></div>

    I have created a custom product field called: mp3purchaselink. In this field I will put in the Miva Code to purchase the download. Can anyone help with what the code would look like to replace the miva purchase code link (http://www.invinciblemusic.com/mm5/m...=1&Action=ADPR) with the custom field that is going to have the purchase code in it?

    Thanks::-))
    Last edited by InvincibleRecordings; 08-01-12, 05:41 PM.
    http://www.invinciblemusic.com

    #2
    Re: How do I code a button with custom product field to be used as a order product l

    "In this field I will put in the Miva Code to purchase the download."

    What does this "Miva Code" look like?

    Comment


      #3
      Re: How do I code a button with custom product field to be used as a order product l

      Liv

      Creating an add to basket link has potential side affects.

      When Google and other web bots browse your site, they will follow the link and add things to the basket. if the link is on every product page, they can potentially slow down your site as dozens, hundreds or even thousands of bogus items are added to the basket.

      For example, I just click your link above and added the item to the basket. So when a bot browses this forum page, they are going to follow the link just as I did an add something to the basket. Its better for these to be forms. (bots don'y usually click buttons)

      In the form you can directly code the product_code value.

      To answer your question, on the Product Display tab you will find a checkbox that makes selected custom field values available.

      After checking the box for
      mp3purchaselink, you can access the value.

      Make sure the form for this button is NOT INSIDE the other <form> and use this...

      Code:
      <input type="hidden" name="product_code" value="&mvte:product:customfield_values:customfields:
      mp3purchaselink
      ;" />
      FYI Notice I used &mvte:

      In forms always use &mvte:
      In links always use &mvta:

      If you are just printing to the screen you can use use &mvt: or &mvte:
      Last edited by RayYates; 08-02-12, 06:27 AM.
      Ray Yates
      "If I have seen further, it is by standing on the shoulders of giants."
      --- Sir Isaac Newton

      Comment


        #4
        Re: How do I code a button with custom product field to be used as a order product l

        Thanks nottheusual1 and Ray for giving thought to this. Ray I tried to create the purchase button using your code concept but I am just lacking programming skills with this kind of form. I did get the custom field to work using this code:
        Code:
        <div id="prodadd"><input type="image" src="graphics/en-US/new/add_to_basket.gif" border="0" /></div>
        <div id="prodadd"><a href="&mvt:product:customfield_values:customfields:mp3purchaselink "><input type="image" src="graphics/en-US/new/add-mp3-yoga-music-to-cart.jpg" border="0" /></div>
        If you had the time (and i know your very busy) to spell the code out using a form I would much prefer to use that.

        I don't want to slow my site down. We are going to add many new download customers as soon as I get the product pages streamlined so this could be a bigger issue down the line. We already have about 500 products.

        The test page I am using is here: http://www.invinciblemusic.com/test3
        http://www.invinciblemusic.com

        Comment


          #5
          Re: How do I code a button with custom product field to be used as a order product l

          Take a look at the form on the page template. <form> </form>

          You need to duplicate that. Get the <input> fields "hidden" and the quantity text box strip out all the html.
          Change the quantity textbox type to hidden change insert a value of 1.

          Change the custom field so it contains the product code you want to sell NOT the add to cart link

          Change the hidden field value for name="product_code" as shown in the original post.
          Ray Yates
          "If I have seen further, it is by standing on the shoulders of giants."
          --- Sir Isaac Newton

          Comment


            #6
            Re: How do I code a button with custom product field to be used as a order product l

            FYI. not certain, but I believe if you use use

            onclick="window.location = 'http://here's the link';" as in:

            <a href="#" onclick="window.location = 'http://here's the link';">Click this </a>

            Search bots wont follow it.
            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


              #7
              Re: How do I code a button with custom product field to be used as a order product l

              That's true. Will Google Analytics will report a 404 error.
              Ray Yates
              "If I have seen further, it is by standing on the shoulders of giants."
              --- Sir Isaac Newton

              Comment


                #8
                Re: How do I code a button with custom product field to be used as a order product l

                I would like to go forward on the form programming to prevent the problem - hopefully. Ray and Bruce, you guys are digit web geniuses and when you talk about how to do coding concepts without spelling out the final code, it just leaves me in the dust. I only understand a fraction of the terminology.

                Ray, I know your VERY busy but can you spell out the actual code for the form for me to paste in. If you want me to send you a payment that is all good as I know your value, I just want to get it done as they say. Here is the test page http://www.invinciblemusic.com/test3 and the code I am using is:

                <div id="prodadd"><input type="image" src="graphics/en-US/new/add_to_basket.gif" border="0" /></div>
                <div id="prodadd"><a href="&mvt:product:customfield_values:customfields :mp3purchaselink "><input type="image" src="graphics/en-US/new/add-mp3-yoga-music-to-cart.jpg" border="0" /></div>
                http://www.invinciblemusic.com

                Comment


                  #9
                  Re: How do I code a button with custom product field to be used as a order product l

                  I think (hope) the add Mp3 to cart button is in a form now:


                  <form method="post" action="http://www.invinciblemusic.com/mm5/merchant.mvc?"><input type="hidden" name="Action" value="ADPR"><input type="hidden" name="Screen" value="PROD"><input type="hidden" name="Store_Code" value="IM"><input type="hidden" name="Product_Code" value="test3"><input type="hidden" name="Category_Code" value="gong-music"><br /><table cellpadding="0" cellspacing="0" border="0"><input type="hidden" name="Product_Attributes[1]:code" value="Free-download-Included"><h6></h6><tr><td align="left" valign="middle"><input type="checkbox" name="Product_Attributes[1]:value" value="Yes">Select Free Complete Album Download with CD Purchase</td></tr></table><input type="hidden" name="Product_Attribute_Count" value=""></h5><br /><h5>Quantity:&nbsp;</h5><input type="text" name="Quantity" value=1 size=4><div id="prodadd"><input type="image" src="graphics/en-US/new/add_to_basket.gif" border="0" /></div><div id="prodadd"><a href="http://www.invinciblemusic.com/mm5/merchant.mvc?Screen=BASK&Store_Code=IM&Product_Cod e=DLM-blue-star&Attributes=Yes&Quantity=1&Action=ADPR"><img src="graphics/en-US/new/add-mp3-yoga-music-to-cart.jpg" border="0" /></a></div></form>
                  http://www.invinciblemusic.com

                  Comment


                    #10
                    Re: How do I code a button with custom product field to be used as a order product l

                    Liv

                    Any link (a href="") can be converted to a <form> and vice versa. With the HTML stripped out The original add to basket form on this page looks like this.

                    Code:
                    <form method="post" action="http://www.invinciblemusic.com/mm5/merchant.mvc?">    <input type="hidden" name="Action" value="ADPR">
                        <input type="hidden" name="Screen" value="PROD">
                        <input type="hidden" name="Store_Code" value="IM">
                        <input type="hidden" name="Product_Code" value="test3">
                        <input type="hidden" name="Category_Code" value="gong-music">
                        <input type="hidden" name="Product_Attributes[1]:code" value="Free-download-Included">
                        <input type="checkbox" name="Product_Attributes[1]:value" value="Yes">
                        Select Free Complete Album Download with CD Purchase
                        Quantity: <input type="text" name="Quantity" value=1 size=4>
                        <input type="image" src="graphics/en-US/new/add_to_basket.gif" border="0" />
                    </form>
                    The link you want to turn into a form looks like this

                    Code:
                    <a href="http://www.invinciblemusic.com/mm5/merchant.mvc?Screen=BASK&Store_Code=IM&Product_Code=DLM-blue-star&Attributes=Yes&Quantity=1&Action=ADPR">
                    Examine both and you will find they have these things in common.
                    http://www.invinciblemusic.com/mm5/merchant.mvc?
                    Screen = somevalue
                    Store_Code = somevalue
                    Product_Code = somevalue
                    Action = somevalue

                    I copied the original form and made the changes needed to add "DLM-blue-star" to the basket.

                    Code:
                    <form method="post" action="http://www.invinciblemusic.com/mm5/merchant.mvc?">
                        <input type="hidden" name="Action" value="ADPR">
                        <input type="hidden" name="Screen" value="BASK">
                        <input type="hidden" name="Store_Code" value="IM">
                        <input type="hidden" name="Product_Code" value="DLM-blue-star">
                        <input type="hidden" name="Category_Code" value="gong-music">
                        <input type="hidden" name="Quantity" value=1>
                        <input type="image" src="graphics/en-US/new/add-mp3-yoga-music-to-cart.jpg" border="0" />
                    </form>
                    In both of these cases Product_Code is a variable name and "DLM-blue-star" is a variable value.

                    To Miva <input type="hidden" name="Product_Code" value="DLM-blue-star"> is the same as Product_Code=DLM-blue-star
                    When submitted to your store, each of these arrive as the global variable g.Product_Code

                    IMPORTANT: If you look at the page template you will find most of these values are not "hard coded" but instead contain an &mvt: tag. These tags print out some variable so that I use &mvt:global:product_code; it will print that variable to the screen. In the case of forms you see something like this

                    <input type="hidden" name="Store_Code" value="&mvt:store:code;">
                    <input type="hidden" name="Product_Code" value="&mvt:product:code;">


                    SO... While the hard coded form I posted above will add DLM-blue-star to the basket You can't just hard coded the value. All of that brings me back to my original posting. Your custom field does not need to contains the link, it only needs the product code you want to add to the basket.

                    Code:
                    <input type="hidden" name="product_code" value="&mvte:product:customfield_values:customfields:
                    mp3purchaselink;" />
                    The FINAL VERSION of the form looks like this. Make sure this form is AFTER the other closing </form> tag. (forms can not be nested)

                    Code:
                    <form method="post" action="&mvte:global:sessionurl;">    <input type="hidden" name="Action" value="ADPR">
                        <input type="hidden" name="Screen" value="BASK">
                        <input type="hidden" name="Store_Code" value="&mvt:global:store:code;">
                        <input type="hidden" name="Product_Code" value="&mvte:product:customfield_values:customfields:mp3purchaselink;">
                        <input type="hidden" name="Category_Code" value="&mvt:global:category_code;">
                        <input type="hidden" name="Quantity" value=1>
                        <input type="image" src="graphics/en-US/new/add-mp3-yoga-music-to-cart.jpg" border="0" />
                    </form>
                    Hope this helps.
                    Ray Yates
                    "If I have seen further, it is by standing on the shoulders of giants."
                    --- Sir Isaac Newton

                    Comment


                      #11
                      Re: How do I code a button with custom product field to be used as a order product l

                      Thanks Ray for the Details! This is how the code looks now with your additions:

                      Code:
                      <h5>
                        <form method="post" action="&mvt:global:sessionurl;">
                         <input type="hidden" name="Action" value="ADPR">
                         <input type="hidden" name="Screen" value="PROD">
                         <input type="hidden" name="Store_Code" value="&mvte:store:code;">
                         <input type="hidden" name="Product_Code" value="&mvte:product:code;">
                         <input type="hidden" name="Category_Code" value="&mvte:global:category_code;">
                         <mvt:item name="product_attributes" param="product:id" />
                         </h5>
                         <br />
                         <h5>Quantity:&nbsp;</h5>
                         <input type="text" name="Quantity" value=1 size=4>
                         <div id="prodadd">
                          <input type="image" src="graphics/en-US/new/add_to_basket.gif" border="0" />
                         </div>
                      </form>
                      
                      
                      <form method="post" action="&mvte:global:sessionurl;">    
                          <input type="hidden" name="Action" value="ADPR">
                          <input type="hidden" name="Screen" value="BASK">
                          <input type="hidden" name="Store_Code" value="&mvte:store:code;">
                          <input type="hidden" name="Product_Code" value="&mvte:product:customfield_values:customfields:mp3purchaselink;">
                          <input type="hidden" name="Category_Code" value="&mvt:global:category_code;">
                          <input type="hidden" name="Quantity" value=1>
                          <input type="image" src="graphics/en-US/new/add-mp3-yoga-music-to-cart.jpg" border="0" />
                      </form>
                      </mvt:if>
                      My test page is here: http://www.invinciblemusic.com/ambika-devi/enchantment

                      When I click on the Add MP3 Album to cart I get this error message:

                      Miva Merchant has encountered a fatal error and is unable to continue. The following information may assist you in determining the cause of the error:

                      Error Code: EOF
                      Description: Record not found: MER-DBE-RNT-00018
                      Other Information:
                      http://www.invinciblemusic.com

                      Comment


                        #12
                        Re: How do I code a button with custom product field to be used as a order product l

                        OK OK Ray = You gave me the CORRECT Code! I entered the wrong value into the product code field (putting the whole url link in) You explained very clearly how do do this correctly and I just was not ready it.

                        Thanks for your help and it works great!
                        Last edited by InvincibleRecordings; 08-05-12, 08:43 AM.
                        http://www.invinciblemusic.com

                        Comment

                        Working...
                        X