Announcement

Collapse
No announcement yet.

ADPM Multiple of the same product with different attributes

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

    ADPM Multiple of the same product with different attributes

    I’m trying to use Miva’s ADPM action to add multiple products to a cart at once. Or rather, the same product multiple times for each attribute option selection. (Ex: Shirt1 A: Size O:XS Q:1, Shirt1 A: Size O:XS Q:3, etc.). The ADPM example is for multiple different products with a single attribute option, but I think I can still use it this way. However, I’m not sure I’m setting it up right (I’m new to MivaScript).

    It fires off the action and takes me to the cart, but it doesn’t add anything. It also opens the cart in a new window rather than pulling it up in a side panel like it did before.

    #2
    For each attribute option I have these inputs:
    <input type=“hidden” name=“Products[ &mvt:product:id; ]:attributes[ &mvt:attribute:index; ]:code” value=“&mvte:option:code;” />
    <input type=“hidden” name=“Products[ &mvt:product:id; ]:code” value=“&mvte:product:code;“>
    <input id=“&mvte:option:code” class=“c-form-input c-control-group__field u-text-center u-color-gray-40 c-button__table” type=“text” inputmode=“decimal” name=“Products[ &mvt:product:id; ]:quantity” value=“0">

    Comment


      #3
      Originally posted by rwilder View Post
      I’m trying to use Miva’s ADPM action to add multiple products to a cart at once. Or rather, the same product multiple times for each attribute option selection. (Ex: Shirt1 A: Size O:XS Q:1, Shirt1 A: Size O:XS Q:3, etc.). The ADPM example is for multiple different products with a single attribute option, but I think I can still use it this way. However, I’m not sure I’m setting it up right (I’m new to MivaScript).
      I think I am understanding your intentions and the ADPM functionality will not work in this case. If you are trying to add the same product as separate line items in the basket they would need to be different with a unique attribute applied or the basket items loop needs to be custom coded. My suggestion would be to add a text field attribute to the product. On the PROD page in attributes template and in the basket options loop hide attribute. Using JavaScript or Miva template code the text field can be populated with a unique string. This would add the product to the basket as a new line item each time that value is different.

      Originally posted by rwilder View Post
      It fires off the action and takes me to the cart, but it doesn’t add anything. It also opens the cart in a new window rather than pulling it up in a side panel like it did before.
      This sounds like there might be an issue with the default theme JavaScript. The AJAX add to cart functionality has a trigger in the HTML that was possibly removed, are there any JavaScript errors.
      Nicholas Adkins
      Technical Training Specialist / Miva, Inc.
      [email protected]
      https://www.miva.com/mivalearn

      Comment


        #4
        Originally posted by Nick View Post
        I think I am understanding your intentions and the ADPM functionality will not work in this case. If you are trying to add the same product as separate line items in the basket they would need to be different with a unique attribute applied or the basket items loop needs to be custom coded. My suggestion would be to add a text field attribute to the product. On the PROD page in attributes template and in the basket options loop hide attribute. Using JavaScript or Miva template code the text field can be populated with a unique string. This would add the product to the basket as a new line item each time that value is different.


        This sounds like there might be an issue with the default theme JavaScript. The AJAX add to cart functionality has a trigger in the HTML that was possibly removed, are there any JavaScript errors.
        Thanks for the reply! I was worried it might have issues with it being the same product... I'm not sure what you mean by the text field attribute though? Do you mean a literal product attribute? Or something else?

        Comment


          #5
          Originally posted by rwilder View Post
          ... I'm not sure what you mean by the text field attribute though? Do you mean a literal product attribute? Or something else?
          Yes, a text field attribute assigned to the product. It would be strictly used for having the product as a separate line item so it should be hidden on the product page and basket loop.

          This way when a unique value is assigned to then textfield and added to the basket the item will be assigned a unique basket line item.
          Nicholas Adkins
          Technical Training Specialist / Miva, Inc.
          [email protected]
          https://www.miva.com/mivalearn

          Comment


            #6
            Perhaps I'm missing how that would be different than having a different attribute option chosen for size every time? That would, in theory, already make the products distinct.

            I'll give it a shot though.

            Comment


              #7
              The unique product index is needed by the ADPM "function" in miva, not for the basket functions.
              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


                #8
                This solution is getting rather complicated, with template code on multiple pages and the adding of "phantom" attributes to items in the basket. In case you'd like a cleaner solution, I'll mention that I've written modules to do this. For example, if a product comes in six sizes and four colors, the module can display a nice grid of 24 text boxes, arranged in rows and columns by size and color. So the customer can just fill in the desired quantity for each one. If that's of interest, you can PM or email me to discuss the details.

                Thanks and Happy New Year! --
                Kent Multer
                Magic Metal Productions
                http://TheMagicM.com
                * Web developer/designer
                * E-commerce and Miva
                * Author, The Official Miva Web Scripting Book -- available on-line:
                http://www.amazon.com/exec/obidos/IS...icmetalproducA

                Comment


                  #9
                  I still think I'm not quite sure how the this ghost attribute would work to provide me with a unique index for the product and not just another attribute value.

                  I was wondering if perhaps I could somehow get at the related product id inside every attribute option for size variants and if that would satisfy the ADPM function, or if it needs to be the master product code.

                  Comment


                    #10
                    Originally posted by Nick View Post
                    I think I am understanding your intentions and the ADPM functionality will not work in this case.
                    Hey Nick, with all due respect, I think this may not be correct. For example, suppose a store sells sports uniforms, and it's common for customers to buy a bunch of them in different sizes. So they set up a page to purchase multiple products via ADPM. One will have a value "L" for the Size attribute, while others may have "M," "S," etc. There's no need for an extra attribute to make them unique, because they already are unique. Or am I missing something?

                    Kent Multer
                    Magic Metal Productions
                    http://TheMagicM.com
                    * Web developer/designer
                    * E-commerce and Miva
                    * Author, The Official Miva Web Scripting Book -- available on-line:
                    http://www.amazon.com/exec/obidos/IS...icmetalproducA

                    Comment


                      #11
                      I think I may have found the problem (or a problem anyway). Out of the box, Miva shadows has a datahook on that form called purchase that says that if the action is anything other than ADPR, then it should just return without doing anything. This was buried in the extensions JS file.

                      purchaseForm.addEventListener('submit', function (evt) {
                      if (purchaseFormActionInput.value !== 'ADPR') {
                      return;
                      }
                      ...
                      }

                      Commenting out that if statement at least get's the same behavior as ADPR in terms of the cart, although it's still not adding anything...
                      Last edited by rwilder; 12-31-20, 02:01 PM.

                      Comment

                      Working...
                      X