PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Getting an Item Quantity

  1. Jessica Rousseau Design
    Member

    Hi I am trying to create a from that will change the shipping price based on specific item quantity.
    X = Product 1 = 6 books
    Y = Product 2 = 1 book
    Z = Product 3 = 1 book
    ....

    How can I access the X quantity? I am trying the :

    add_filter("gform_product_info_1", "add_fee", 10, 3);
    function add_fee($product_info, $form, $lead){
    $quantity = $product_info["products"][1]["quantity"];

    but I just can't figure how to get the quantity for that specific element.
    And how to get form quantity and general as well.

    I am trying to create something like this:

    if ( X quantity > 1 )
      { total = (total + (X quantity* shipping cost)) - shipping cost;
      }else {
          if ( X,Y,Z quantity of the form > 6 ) {
           total = (total + (X,Y,Z quantity/6)*shipping cost)- shipping cost;
         }
    }

    So all I really need is the ability to access X quantity, and total form quantity.

    Any help will be greatly appreciated.
    Thank you.

    Posted 13 years ago on Wednesday October 12, 2011 | Permalink
  2. Hi Jessica,

    Here are two little helper functions that you can pass the $product_info variable to and retrieve the desired information.

    http://pastie.org/2689776

    Look for get_product_quantity and get_order_quantity in the snippet above.

    Posted 13 years ago on Thursday October 13, 2011 | Permalink

This topic has been resolved and has been closed to new replies.