Results 1 to 3 of 3
  1. #1
    Join Date
    May 2006
    Posts
    45
    Plugin Contributions
    0

    How to get products attributes from cart?

    I need to walk through all the products in the cart to see if defined products exist. Function below works just fine with IDīs, no matter if products come with attributes or without them. It just returns products clear ID from the cart without :43fds45.... ending.


    function get_products_id() {

    if (!is_array ($products_id_array)) $products_id_array = array();

    $products = $_SESSION['cart']->get_products();
    for ($i=0; $i<sizeof($products); $i++) {
    $products_id_array[] = zen_get_prid($products[$i]['id']);
    }
    return $products_id_array;
    }


    BUT!!! How do I get options_value_idīs with products IDīs if them exist in the cart?? So I need to have output with products_id and products_options_value_id (or at least products final_price) just something with to recognize products attributes.

    I hope there is an easy answer for this...or actually any kind of answer!

    -Jarsa-.

  2. #2
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: How to get products attributes from cart?

    Kinda depends on the use. What are you planning to do with this information?
    .

    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.

  3. #3
    Join Date
    May 2006
    Posts
    45
    Plugin Contributions
    0

    Default Re: How to get products attributes from cart?

    Ciao!

    I allready solved my problem. It may not be very stylish solution, but it works fine for me. Function returns products_options_values_id to calling class when products_id and its options_id are given.

    This function returns only one option_values_id because there can be only one of these products in my customers cart. If cart contains several same product_idīs, returned value will be the last added options value_id.


    function get_products_options_values_id($products_id, $option_id) {

    $products = $_SESSION['cart']->get_products();
    for ($i=0; $i<sizeof($products); $i++) {
    $products_id_array[] = zen_get_prid($products[$i]['id']);
    $products_attributes_array[] = products[$i]['attributes'][$option_id];
    }

    $products_options_array = array_combine($products_id_array, $products_attributes_array);
    foreach ($products_options_array as $products_id => $products_options_values_id) {

    return $products_options_values_id;
    }
    }


    Iīll be asking more questions soon ,
    Jarsa

 

 

Similar Threads

  1. How to get attributes above add to cart?
    By jabbott in forum Customization from the Admin
    Replies: 2
    Last Post: 12 Apr 2013, 02:17 PM
  2. Replies: 2
    Last Post: 2 Jan 2012, 11:22 PM
  3. transfering categories, products, and attributes from one zen cart to another
    By jujubeanie in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 11 Jul 2009, 12:58 AM
  4. How to build products quantity from attributes?
    By Intersfer in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 11 Sep 2006, 10:34 PM

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