Search code examples
joomlaparent-childjoomla1.5virtuemart

Virtuemart - Need my AddtoCart Form to show Children of Extra ID Products ONLY


I am attempting to make an online store that sells DVDs, VHSs, CDs and Digital Products. The Digital Products will be broken down into singles.

I have created two (2) Product Parents: "Product" and "Product Singles" "Product" has three (3) Children: "DVD", "CD" and "Download" "Product Singles" has three (4) Children: "Track1", "Track2", "Track3" and "Track4"

In "Product"s Extra IDs field I input the Product ID of "Product Singles".

Now, my AddtoCart Form is listing all seven (7) Children.

I created a 2nd AdtoCart Form titled addtocart_form2.tpl.php which is an exact copy of addtocart_form.tpl.php

In the ps_product_attribute.php file, I created a duplicate function called list_attribute_list2 which controls the list that appears in the AddtoCart Form.

I had my Flypage show addtocart_form.tpl.php in the top right and blocked out the code that would add the Extra IDs. It worked.

I had my Flypage show addtocart_form.tpl.php at the bottom. It worked.

Now, I'd like to change the code on addtocart_form2.tpl.php to allow for ONLY the Extra ID Children to appear.

But this is where I'm stuck, I don't know how to change the code to ONLY show the Extra IDs Children and NOT the Parent "Product"s Children.

Any help would be appreciated.


Solution

  • In the shop.product_details.php file:

    I created a second instance of the variable $q and caled it $q2

    after $db_product->query( $q ); ran the query on the Database, $db_product was now set as the entire row where 'product_id' = $product_id

    Then I inserted the following code:

    $product_id2_str = $db_product->f("child_option_ids");
    $product_id2_arr = explode(",",$product_id2_str);
    $product_id2 = intval($product_id2_arr[0]);
    $db_product2 = new ps_DB;
    

    In other words, I fetched 'child_option_ids' as a string, then created an array. Then, I transferred the first number in the array to $product_id2.

    After that, I pretty much just made copies of anything where $product_id was important.

    If you need more help, I guess just comment and I'll write the rest, but this was the main problem I was having.