Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

I need to know a varible


jlh42581

Recommended Posts

Can anyone tell me how to draw out Attribute 1 and Attribute 2?

 

Tried these:

$products_attributes[0]['value_id'] - for attribute one

$products_attributes[1]['value_id'] - for attribute two

 

Also Tried This:

$order->products[$i]['attributes'][0] - for attribute one

$order->products[$i]['attributes'][1] - for attribute two

 

Where i need to edit this is on checkout_process.php

 

Roughly line 136 - 160

 

Part of this file is a require from order.php located under catalog/includes/classes/

 

Thanks

 

Jeremy

Link to comment
Share on other sites

Can anyone tell me how to draw out Attribute 1 and Attribute 2?

 

Tried these:

$products_attributes[0]['value_id'] - for attribute one

$products_attributes[1]['value_id'] - for attribute two

 

Also Tried This:

$order->products[$i]['attributes'][0] - for attribute one

$order->products[$i]['attributes'][1] - for attribute two

 

Where i need to edit this is on checkout_process.php

 

Roughly line 136 - 160

 

Part of this file is a require from order.php located under catalog/includes/classes/

 

Thanks

 

Jeremy

 

Hi Jeremy,

 

can you gove an example in product names and attribute names please? I'm sorry I do not understand what you would like to get and why.

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

Hi Jeremy,

 

can you gove an example in product names and attribute names please? I'm sorry I do not understand what you would like to get and why.

 

 

Its already grabing the product id for whatever is in the cart for the original inventory update, ive created a custom inventory system to track items by attributes so now the stock update at the lines given above needs to be edited to remove it by attribute instead of a product as a whole. I know its storing these varibles somewhere because it needs to alert admin to the product name, size and color that the person has chosen.

 

example would be :

 

Shoe - product_id

Color - attribute_one

Size - attribute_two

Link to comment
Share on other sites

Its already grabing the product id for whatever is in the cart for the original inventory update, ive created a custom inventory system to track items by attributes so now the stock update at the lines given above needs to be edited to remove it by attribute instead of a product as a whole. I know its storing these varibles somewhere because it needs to alert admin to the product name, size and color that the person has chosen.

 

example would be :

 

Shoe - product_id

Color - attribute_one

Size - attribute_two

 

sorry I still do not understand, but you want to look into the contrib for QTYPro as it has attributes and stock for them. Check out what they did for checkout process, that might help you. I use it, so if you want it I can post just the snippet for you that deals with stock.

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

Monika,

 

Please post the snippet for me from the checkout_proces.php and order.php - The piece with attributes.

 

I tried using it but this is the old version and there were too many products already entered to make it usefull.

 

Thanks,

 

Jeremy

Link to comment
Share on other sites

Monika,

 

Please post the snippet for me from the checkout_proces.php and order.php - The piece with attributes.

 

I tried using it but this is the old version and there were too many products already entered to make it usefull.

 

Thanks,

 

Jeremy

 

from checkout_process:

 

// initialized for the email confirmation
 $products_ordered = '';
 $subtotal = 0;
 $total_tax = 0;

 for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
// Stock Update - Joao Correia
//++++ QT Pro: Begin Changed code
   $products_stock_attributes=null;
   if (STOCK_LIMITED == 'true') {
       $products_attributes = $order->products[$i]['attributes'];
//      if (DOWNLOAD_ENABLED == 'true') {
//++++ QT Pro: End Changed Code
       $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename 
                           FROM " . TABLE_PRODUCTS . " p
                           LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                            ON p.products_id=pa.products_id
                           LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                            ON pa.products_attributes_id=pad.products_attributes_id
                           WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'";
// Will work with only one option for downloadable products
// otherwise, we have to build the query dynamically with a loop
//++++ QT Pro: Begin Changed code
//      $products_attributes = $order->products[$i]['attributes'];
//++++ QT Pro: End Changed Code
     if (is_array($products_attributes)) {
       $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
     }
     $stock_query = tep_db_query($stock_query_raw);
     if (tep_db_num_rows($stock_query) > 0) {
       $stock_values = tep_db_fetch_array($stock_query);
//++++ QT Pro: Begin Changed code
       $actual_stock_bought = $order->products[$i]['qty'];
       $download_selected = false;
       if ((DOWNLOAD_ENABLED == 'true') && isset($stock_values['products_attributes_filename']) && tep_not_null($stock_values['products_attributes_filename'])) {
         $download_selected = true;
         $products_stock_attributes='$$DOWNLOAD$$';
       }
//      If not downloadable and attributes present, adjust attribute stock
       if (!$download_selected && is_array($products_attributes)) {
         $all_nonstocked = true;
         $products_stock_attributes_array = array();
         foreach ($products_attributes as $attribute) {
           if ($attribute['track_stock'] == 1) {
             $products_stock_attributes_array[] = $attribute['option_id'] . "-" . $attribute['value_id'];
             $all_nonstocked = false;
           }
         } 
         if ($all_nonstocked) {
           $actual_stock_bought = $order->products[$i]['qty'];
         }  else {
           asort($products_stock_attributes_array, SORT_NUMERIC);
           $products_stock_attributes = implode(",", $products_stock_attributes_array);
           $attributes_stock_query = tep_db_query("select products_stock_quantity from " . TABLE_PRODUCTS_STOCK . " where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
           if (tep_db_num_rows($attributes_stock_query) > 0) {
             $attributes_stock_values = tep_db_fetch_array($attributes_stock_query);
             $attributes_stock_left = $attributes_stock_values['products_stock_quantity'] - $order->products[$i]['qty'];
             tep_db_query("update " . TABLE_PRODUCTS_STOCK . " set products_stock_quantity = '" . $attributes_stock_left . "' where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");

             $actual_stock_bought = ($attributes_stock_left < 1) ? $attributes_stock_values['products_stock_quantity'] : $order->products[$i]['qty'];
           } else {
             $attributes_stock_left = 0 - $order->products[$i]['qty'];
             tep_db_query("insert into " . TABLE_PRODUCTS_STOCK . " (products_id, products_stock_attributes, products_stock_quantity) values ('" . tep_get_prid($order->products[$i]['id']) . "', '" . $products_stock_attributes . "', '" . $attributes_stock_left . "')");
             $actual_stock_bought = 0;
           }
         }
       }
//        $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
//      }
//      if (tep_db_num_rows($stock_query) > 0) {
//        $stock_values = tep_db_fetch_array($stock_query);
// do not decrement quantities if products_attributes_filename exists
       if (!$download_selected) {
         $stock_left = $stock_values['products_quantity'] - $actual_stock_bought;
         tep_db_query("UPDATE " . TABLE_PRODUCTS . " 
                       SET products_quantity = products_quantity - '" . $actual_stock_bought . "' 
                       WHERE products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
//++++ QT Pro: End Changed Code
         if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {
           tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
         }
       }
     }
//++++ QT Pro: Begin Changed code
   }
//++++ QT Pro: End Changed Code

// 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']) . "'");

//++++ QT Pro: Begin Changed code
   if (!isset($products_stock_attributes)) $products_stock_attributes=null;
   $sql_data_array = array('orders_id' => $insert_id, 
                           'products_id' => tep_get_prid($order->products[$i]['id']), 
                           'products_model' => $order->products[$i]['model'], 
                           'products_name' => $order->products[$i]['name'], 
                           'products_price' => $order->products[$i]['price'], 
                           'final_price' => $order->products[$i]['final_price'], 
                           'products_tax' => $order->products[$i]['tax'], 
                           'products_quantity' => $order->products[$i]['qty'],
                           'products_stock_attributes' => $products_stock_attributes);
//++++ QT Pro: End Changed Code
   tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
   $order_products_id = tep_db_insert_id();

//------insert customer choosen option to order--------

 

from order.php

 

        if ($products[$i]['attributes']) {
         $subindex = 0;
         reset($products[$i]['attributes']);
         while (list($option, $value) = each($products[$i]['attributes'])) {
//++++ QT Pro: Begin Changed code
           $attributes_query = tep_db_query("select popt.products_options_name, popt.products_options_track_stock, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)$products[$i]['id'] . "' and pa.options_id = '" . (int)$option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int)$value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . (int)$languages_id . "' and poval.language_id = '" . (int)$languages_id . "'");
//++++ QT Pro: End Changed Code
           $attributes = tep_db_fetch_array($attributes_query);

//++++ QT Pro: Begin Changed code
           $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options_name'],
                                                                    'value' => $attributes['products_options_values_name'],
                                                                    'option_id' => $option,
                                                                    'value_id' => $value,
                                                                    'prefix' => $attributes['price_prefix'],
                                                                    'price' => $attributes['options_values_price'],
                                                                    'track_stock' => $attributes['products_options_track_stock']);
//++++ QT Pro: End Changed Code

           $subindex++;

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...