osCommerce Community Support Forums: Cost of Goods Sold report - osCommerce Community Support Forums

Jump to content

Corporate Sponsor


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Cost of Goods Sold report tracking cost of goods sold on orders Rate Topic: -----

#1 User is offline   YogiSoap Icon

  • Find Posts
  • Group: Community Member
  • Posts: 34
  • Joined: 24-September 02
  • Real Name:Kevin Lincicome
  • Location:Boulder, CO

Posted 01 May 2005 - 10:42 PM

I am trying to create a Cost of Goods Sold Report contribution; something that I needed for tax time. I seem to be stuck on how items are added to a table on checkout. Any help would be greatly appreciated.......

Here is what has been done so far;

I have added a cost field to the product table as per the "Shop Owner Product Cost" contribution. I also added a contribution "Products Purchased with Date Range" which allows you to view gross sales per product for a date range. I then added to the orders_products table a product_cost field. Being that the orders I wanted a "cost of goods" report on were old, I then used phpMyAdmin and manually entered a cost of every product sold in that range. I then tweaked the "Products Purchased with Date Range" mod to report a cost column instead of a gross sales column. All is working beautifully. I don't think this is a practical solution, however, as the manual entry with phpMyAdminis tedious at best.

Now, it seems to me that if the "products" table has a "products_cost" field (added with 1st mod mentioned), then this could be recorded at the time of checkout along with the other fields that are entered into the "orders_product" table. Recording the cost at the time of the sale seems to make the best sense to account for changing costs of one's products, should they vary with time. I can not seem to get it entered though. I have changed code in the checkout_process.php, classes/general.php, shopping_cart.php, classes/orders.php, and probably 3 or 4 others as well and I can not get it to work.

I guess my first question is: when is a product's info "selected" for insertion into the various tables upon checkout? When added to the basket? When the "Checkout Now" button is clicked? It seems like only the "product_id" is selected and carried through until the "checkout_process.php" step when "products_name", "products_model", etc. are then querried and added to the "orders_products" table. Which would make the following code work:


Quote

       
(from the checkout_process.php page, around line 157):

// Update products_ordered (for bestsellers list)
    tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");

    $sql_data_array = array('orders_id' => $insert_id,
                            'products_id' => tep_get_prid($order->products[$i]['id']),
                            'products_name' => $order->products[$i]['name'],
                            'products_price' => $order->products[$i]['price'],
                          'products_cost' => $order->products[$i]['cost'],
                            'final_price' => $order->products[$i]['final_price'],
                            'products_tax' => $order->products[$i]['tax'],
                            'products_quantity' => $order->products[$i]['qty'],
                            'products_model' => $order->products[$i]['model']);
    tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
    $order_products_id = tep_db_insert_id();


Unfortunately, it does not, and I have searched everywhere to find a solution. For the sake of the remaining hair on my head I am asking anyone with a little clearer insight as to how the cart works and the checkout process is handled to help!

Sorry for the long post, I do hope it is clear enough. Please ask if you still have ???.

Kevin
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic