News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

SOLVED products listed in 2 categories end up twice in confirmations and back-en

Started by Lexiboy, February 15, 2012, 19:57:23 PM

Previous topic - Next topic

Lexiboy

(Joomla 1.7.3 and VM 2.0.1)

When I place an order and check out, every things goes fine. All items appear once in the basked.
But in the confirmation mail of the order, products that are listed in two categores end up double. Items that are in only one category do not have the problem. The total amount of the card is correct.  The same happens in de back-end.

In the database the order is correct, so no duplicated items.

How can I solve this?

After some digging I think  I found the mysql query responsible for the results, can someone more skilled than I see if it has a mistake in it?


/administrator/components/com_virtuemart/models/orders.php, line 155 and on:

$q = "SELECT virtuemart_order_item_id, product_quantity, order_item_name,
    order_item_sku, i.virtuemart_product_id, product_item_price,
    product_final_price, product_basePriceWithTax, product_subtotal_with_tax, product_subtotal_discount, product_tax, product_attribute, order_status,
    intnotes, virtuemart_category_id
   FROM (#__virtuemart_order_items i
   LEFT JOIN #__virtuemart_products p
   ON p.virtuemart_product_id = i.virtuemart_product_id)
                       LEFT JOIN #__virtuemart_product_categories c
                       ON p.virtuemart_product_id = c.virtuemart_product_id
   WHERE virtuemart_order_id=".$virtuemart_order_id;
                $db->setQuery($q);
                $order['items'] = $db->loadObjectList();
With kind regards,
Alex Stienstra

Lexiboy

I manged to solve the problem, the query mentioned above is bugged.

I added a grouping to the query and the problem was fixed. The query should be rewritten IMHO, this is more a patch than anything else.

Here is the new query:


// Get the order items
$q = "SELECT virtuemart_order_item_id, product_quantity, order_item_name,
    order_item_sku, i.virtuemart_product_id, product_item_price,
    product_final_price, product_basePriceWithTax, product_subtotal_with_tax, product_subtotal_discount, product_tax, product_attribute, order_status,
    intnotes, virtuemart_category_id
   FROM (#__virtuemart_order_items i
   LEFT JOIN #__virtuemart_products p
   ON p.virtuemart_product_id = i.virtuemart_product_id)
                       LEFT JOIN #__virtuemart_product_categories c
                       ON p.virtuemart_product_id = c.virtuemart_product_id
   WHERE virtuemart_order_id=".$virtuemart_order_id." GROUP BY virtuemart_order_item_id";
With kind regards,
Alex Stienstra

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/


Lexiboy

Quote from: Milbo on February 16, 2012, 20:14:47 PM
Strange, this is not fixed already in the K version?

I am not sure what version I have, I think E, not K yet, I installed it last week :) The 2.01 did fix some problems I faced in the 2.0 release. (that were documented)

This patch might be usefull for ppl that stick to final releases, unless this bug appeared in the 2.0.1 pre release.

Btw, I did not read about this bug anywhere else, did I miss something then?

With kind regards,
Alex Stienstra

thinkmoremedia

I have the same issue and tried using your code but it didn't work for me. I'm using version 2.0.2 - it did not display any items I purchased.
I put the old order.php back, removed a category for one of my products and it worked perfectly.

I hope this gets fixed. It not acceptable the way it is - it will confuse customers.
Thanks,

Scott
Think More Media