Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

MVS and Add Weight to Product Attributes


MCousin76

Recommended Posts

Hi,

 

I have "Add Weight To Product Attributes v0.1" and "Multi Vendor Shipping" installed. Both of the contributions work great. However, when i turn the MVS (ON) the product attribute weight does not add, it only uses the original weight set for the product. My thoughts are that i need to add some of the code from the "Add Weight To Product Attributes" contribution and merge it into the "MVS" code. I'm just not sure what and where.

 

Does anyone know how to get this to work?

 

Thanks - Mike C.

 

==========================================

Here is my code for the includes/classes/shopping_cart.php page

(I'm guessing this is the page that needs to be modified)

==========================================

<?php

/*

$Id: shopping_cart.php,v 1.35 2003/06/25 21:14:33 hpdl Exp $

 

Modified for MVS V1.0 2006/03/25 JCK/CWG

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2006 osCommerce

 

Released under the GNU General Public License

*/

 

class shoppingCart {

var $contents, $total, $weight, $cartID, $content_type;

 

function shoppingCart() {

$this->reset();

}

 

function restore_contents() {

global $customer_id;

 

if (!tep_session_is_registered('customer_id')) return false;

 

// insert current cart contents in database

if (is_array($this->contents)) {

reset($this->contents);

while (list($products_id, ) = each($this->contents)) {

$qty = $this->contents[$products_id]['qty'];

$product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

if (!tep_db_num_rows($product_query)) {

tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");

if (isset($this->contents[$products_id]['attributes'])) {

reset($this->contents[$products_id]['attributes']);

while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {

//clr 031714 udate query to include attribute value. This is needed for text attributes.

$attr_value = $this->contents[$products_id]['attributes_values'][$option];

tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')");

}

}

} else {

tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

}

}

}

 

// reset per-session cart contents, but not the database contents

$this->reset(false);

 

$products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");

while ($products = tep_db_fetch_array($products_query)) {

$this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']);

// attributes

//CLR 020606 update query to pull attribute value_text. This is needed for text attributes.

$attributes_query = tep_db_query("select products_options_id, products_options_value_id, products_options_value_text from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'");

while ($attributes = tep_db_fetch_array($attributes_query)) {

$this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];

//CLR 020606 if text attribute, then set additional information

if ($attributes['products_options_value_id'] == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {

$this->contents[$products['products_id']]['attributes_values'][$attributes['products_options_id']] = $attributes['products_options_value_text'];

}

}

}

 

$this->cleanup();

}

 

function reset($reset_database = false) {

global $customer_id;

 

$this->contents = array();

$this->total = 0;

$this->weight = 0;

$this->content_type = false;

 

if (tep_session_is_registered('customer_id') && ($reset_database == true)) {

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'");

}

 

unset($this->cartID);

if (tep_session_is_registered('cartID')) tep_session_unregister('cartID');

}

 

function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {

global $new_products_id_in_cart, $customer_id;

 

$products_id = tep_get_uprid($products_id, $attributes);

if ($notify == true) {

$new_products_id_in_cart = $products_id;

tep_session_register('new_products_id_in_cart');

}

 

if ($this->in_cart($products_id)) {

$this->update_quantity($products_id, $qty, $attributes);

} else {

$this->contents[] = array($products_id);

$this->contents[$products_id] = array('qty' => $qty);

// insert into database

if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");

 

if (is_array($attributes)) {

reset($attributes);

while (list($option, $value) = each($attributes)) {

//CLR 020606 check if input was from text box. If so, store additional attribute information

//CLR 020708 check if text input is blank, if so do not add to attribute lists

//CLR 030228 add htmlspecialchars processing. This handles quotes and other special chars in the user input.

$attr_value = NULL;

$blank_value = FALSE;

if (strstr($option, TEXT_PREFIX)) {

if (trim($value) == NULL)

{

$blank_value = TRUE;

} else {

$option = substr($option, strlen(TEXT_PREFIX));

$attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);

$value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;

$this->contents[$products_id]['attributes_values'][$option] = $attr_value;

}

}

 

if (!$blank_value)

{

$this->contents[$products_id]['attributes'][$option] = $value;

// insert into database

//CLR 020606 update db insert to include attribute value_text. This is needed for text attributes.

//CLR 030228 add tep_db_input() processing

if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')");

}

}

}

}

$this->cleanup();

 

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure

$this->cartID = $this->generate_cart_id();

}

 

function update_quantity($products_id, $quantity = '', $attributes = '') {

global $customer_id;

 

if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true..

 

$this->contents[$products_id] = array('qty' => $quantity);

// update database

if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

 

if (is_array($attributes)) {

reset($attributes);

while (list($option, $value) = each($attributes)) {

//CLR 020606 check if input was from text box. If so, store additional attribute information

//CLR 030108 check if text input is blank, if so do not update attribute lists

//CLR 030228 add htmlspecialchars processing. This handles quotes and other special chars in the user input.

$attr_value = NULL;

$blank_value = FALSE;

if (strstr($option, TEXT_PREFIX)) {

if (trim($value) == NULL)

{

$blank_value = TRUE;

} else {

$option = substr($option, strlen(TEXT_PREFIX));

$attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);

$value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;

$this->contents[$products_id]['attributes_values'][$option] = $attr_value;

}

}

 

if (!$blank_value)

{

$this->contents[$products_id]['attributes'][$option] = $value;

// update database

//CLR 020606 update db insert to include attribute value_text. This is needed for text attributes.

//CLR 030228 add tep_db_input() processing

if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "', products_options_value_text = '" . tep_db_input($attr_value) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'");

}

}

}

}

 

function cleanup() {

global $customer_id;

 

reset($this->contents);

while (list($key,) = each($this->contents)) {

if ($this->contents[$key]['qty'] < 1) {

unset($this->contents[$key]);

// remove from database

if (tep_session_is_registered('customer_id')) {

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");

}

}

}

}

 

function count_contents() { // get total number of items in cart

$total_items = 0;

if (is_array($this->contents)) {

reset($this->contents);

while (list($products_id, ) = each($this->contents)) {

$total_items += $this->get_quantity($products_id);

}

}

 

return $total_items;

}

 

function get_quantity($products_id) {

if (isset($this->contents[$products_id])) {

return $this->contents[$products_id]['qty'];

} else {

return 0;

}

}

 

function in_cart($products_id) {

if (isset($this->contents[$products_id])) {

return true;

} else {

return false;

}

}

 

function remove($products_id) {

global $customer_id;

 

//CLR 030228 add call tep_get_uprid to correctly format product ids containing quotes

$products_id = tep_get_uprid($products_id, $attributes);

 

unset($this->contents[$products_id]);

// remove from database

if (tep_session_is_registered('customer_id')) {

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

}

 

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure

$this->cartID = $this->generate_cart_id();

}

 

function remove_all() {

$this->reset();

}

 

function get_product_id_list() {

$product_id_list = '';

if (is_array($this->contents)) {

reset($this->contents);

while (list($products_id, ) = each($this->contents)) {

$product_id_list .= ', ' . $products_id;

}

}

 

return substr($product_id_list, 2);

}

 

function calculate() {

$this->total = 0;

$this->weight = 0;

if (!is_array($this->contents)) return 0;

 

reset($this->contents);

while (list($products_id, ) = each($this->contents)) {

$qty = $this->contents[$products_id]['qty'];

 

// products price

$product_query = tep_db_query("select products_id, products_price, products_discount, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");

if ($product = tep_db_fetch_array($product_query)) {

$prid = $product['products_id'];

$products_tax = tep_get_tax_rate($product['products_tax_class_id']);

$products_price = $product['products_price'];

 

// Simple Price Break

if( isset($product['products_discount']) && strlen($product['products_discount'])>2 ) {

if( $tranche = explode( ',', $product['products_discount'] ) ) {

foreach( $tranche as $cle => $trn )

if( $qty_px = explode( ':', $trn ) ) {

if( $qty >= $qty_px[0] )

$products_price = $qty_px[1];

}

}

}

// Simple Price Break

 

$products_cost = $product['products_cost'];

$products_weight = $product['products_weight'];

 

$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");

if (tep_db_num_rows ($specials_query)) {

$specials = tep_db_fetch_array($specials_query);

if( $products_price > $specials['specials_new_products_price'] )

$products_price = $specials['specials_new_products_price'];

}

 

$this->total += tep_add_tax($products_price, $products_tax) * $qty;

$this->weight += ($qty * $products_weight);

}

 

// attributes price

// [email protected]

// add-weight-to-product-attributes mod:

// added weight to db query

if (isset($this->contents[$products_id]['attributes'])) {

reset($this->contents[$products_id]['attributes']);

while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {

$attribute_price_query = tep_db_query("select options_values_price, price_prefix, options_values_weight from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");

$attribute_price = tep_db_fetch_array($attribute_price_query);

//bof product setup fee

if ($attribute_price['price_prefix'] == '+') {

$this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);

}

else if ($attribute_price['price_prefix'] == '#') {

$this->total += tep_add_tax($attribute_price['options_values_price'], $products_tax);

}

else {

$this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);

 

//eof

}

if(!empty($attribute_price['options_values_weight'])) {

// [email protected]

// add-weight-to-product-attributes mod:

$this->weight += ($qty * $attribute_price['options_values_weight']);

} // END if(!empty($attribute_price['options_values_weight'])) {

}

}

}

}

 

//////

//MVS Start

// New method to provide cost, weight, quantity, and product IDs by vendor

//////

//Output array structure (example):

//shoppingcart Object

//(

// [vendor_shipping] => array

// (

// [0] => array //Number is the vendor_id

// (

// [weight] => 22.59

// [cost] => 12.95

// [qty] => 2

// [products_id] => array

// (

// [0] => 12

// [1] => 47

// )

// )

// [12] => array

// (

// [weight] => 32.74

// [cost] => 109.59

// [qty] => 5

// [products_id] => array

// (

// [0] => 2

// [1] => 3

// [2] => 37

// [3] => 49

// )

// )

// )

//)

function vendor_shipping() {

 

if (!is_array($this->contents)) return 0; //Cart is empty

 

$this->vendor_shipping = array(); //Initialize the output array

reset($this->contents); // and reset the input array

foreach ($this->contents as $products_id => $value) { //$value is never used

$quantity = $this->contents[$products_id]['qty'];

 

//mod IndvShip, added products_ship_price

$products_query = tep_db_query("select products_id,

products_price,

products_ship_price,

products_tax_class_id,

products_weight,

vendors_id

from " . TABLE_PRODUCTS . "

where products_id = '" . (int)$products_id . "'"

);

if ($products = tep_db_fetch_array($products_query)) {

$products_price = $products['products_price'];

//mod IndvShip

$products_ship_price = $products['products_ship_price'];

//mod IndvShip

$products_weight = $products['products_weight'];

$vendors_id = ($products['vendors_id'] <= 0) ? 1 : $products['vendors_id'];

$products_tax = tep_get_tax_rate($products['products_tax_class_id']);

 

//Find special prices (if any)

$specials_query = tep_db_query("select specials_new_products_price

from " . TABLE_SPECIALS . "

where products_id = '" . (int)$products_id . "'

and status = '1'"

);

if (tep_db_num_rows ($specials_query)) {

$specials = tep_db_fetch_array($specials_query);

$products_price = $specials['specials_new_products_price'];

}

 

//Add values to the output array

$this->vendor_shipping[$vendors_id]['weight'] += ($quantity * $products_weight);

$this->vendor_shipping[$vendors_id]['cost'] += tep_add_tax($products_price, $products_tax) * $quantity;

//mod IndvShip

$this->vendor_shipping[$vendors_id]['ship_cost'] += ($quantity * $products_ship_price);

//mod IndvShip

$this->vendor_shipping[$vendors_id]['qty'] += $quantity;

$this->vendor_shipping[$vendors_id]['products_id'][] = $products_id; //There can be more than one product

}

 

// Add/subtract attributes prices (if any)

if (isset($this->contents[$products_id]['attributes'])) {

reset($this->contents[$products_id]['attributes']);

foreach ($this->contents[$products_id]['attributes'] as $option => $value) {

$attribute_price_query = tep_db_query("select options_values_price,

price_prefix

from " . TABLE_PRODUCTS_ATTRIBUTES . "

where products_id = '" . (int)$products_id . "'

and options_id = '" . (int)$option . "'

and options_values_id = '" . (int)$value . "'"

);

$attribute_price = tep_db_fetch_array($attribute_price_query);

if ($attribute_price['price_prefix'] == '+') {

$this->vendor_shipping[$vendors_id]['cost'] += $quantity * tep_add_tax($attribute_price['options_values_price'], $products_tax);

} else {

$this->vendor_shipping[$vendors_id]['cost'] -= $quantity * tep_add_tax($attribute_price['options_values_price'], $products_tax);

}

}

}

}

 

return $this->vendor_shipping;

}

//MVS End

 

//bof product setup fee

function attributes_price($products_id) {

$attributes_price = 0;

 

if (isset($this->contents[$products_id]['attributes'])) {

reset($this->contents[$products_id]['attributes']);

while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {

$attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");

$attribute_price = tep_db_fetch_array($attribute_price_query);

if ($attribute_price['price_prefix'] == '+') {

$attributes_price += $attribute_price['options_values_price'];

}

else if ($attribute_price['price_prefix'] == '#') {

}

else {

$attributes_price -= $attribute_price['options_values_price'];

}

}

}

return $attributes_price;

}

 

function attributes_setup_price($products_id) {

$attributes_setup_price = 0;

 

if (isset($this->contents[$products_id]['attributes'])) {

reset($this->contents[$products_id]['attributes']);

while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {

$attribute_setup_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");

$attribute_setup_price = tep_db_fetch_array($attribute_setup_price_query);

if ($attribute_setup_price['price_prefix'] == '+') {

}

else if ($attribute_setup_price['price_prefix'] == '#') {

$attributes_setup_price += $attribute_setup_price['options_values_price'];

}

else {

}

}

}

return $attributes_setup_price;

}

 

//eof

 

//MVS - added function to only retrieve specific vendors products

function get_vendors_products($vendor) {

global $languages_id;

 

if (!is_array($this->contents)) return false;

 

$products_array = array();

reset($this->contents);

while (list($products_id, ) = each($this->contents)) {

//MVS start - added v.vendors_id, v.vendors_name, and v.vendors_id = p.vendors_id

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_discount, p.products_cost, p.products_weight, p.products_tax_class_id, v.vendors_id, v.vendors_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_VENDORS . " v where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and v.vendors_id = '" . $vendor . "' and p.vendors_id = '" . $vendor . "' and pd.language_id = '" . (int)$languages_id . "'");

//MVS end

if ($products = tep_db_fetch_array($products_query)) {

$prid = $products['products_id'];

$products_price = $products['products_price'];

 

// Simple Price Break

if( isset($products['products_discount']) && strlen($products['products_discount'])>2 ) {

if( $tranche = explode( ',', $products['products_discount'] ) ) {

foreach( $tranche as $cle => $trn )

if( $qty_px = explode( ':', $trn ) ) {

if( $this->contents[$products_id]['qty'] >= $qty_px[0] )

$products_price = $qty_px[1];

}

}

}

// Simple Price Break

 

$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");

if (tep_db_num_rows($specials_query)) {

$specials = tep_db_fetch_array($specials_query);

if( $products_price > $specials['specials_new_products_price'] )

$products_price = $specials['specials_new_products_price'];

}

 

//clr 030714 update $products_array to include attribute value_text. This is needed for text attributes.

$products_array[] = array('id' => $products_id,

'name' => $products['products_name'],

'model' => $products['products_model'],

'image' => $products['products_image'],

'price' => $products_price,

'cost' => $products['products_cost'],

'quantity' => $this->contents[$products_id]['qty'],

'weight' => $products['products_weight'] + $attributes_total_weight,

'final_price' => ($products_price + $this->attributes_price($products_id)),

'setup_price' => ($this->attributes_setup_price($products_id)), //edit product setup fee

'tax_class_id' => $products['products_tax_class_id'],

//MVS start

'vendors_id' => $products['vendors_id'],

'vendors_name' => $products['vendors_name'],

//MVS end

'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''),

'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''));

 

}

}

 

return $products_array;

}

//MVS - upsxml end

 

function get_products() {

global $languages_id;

 

if (!is_array($this->contents)) return false;

 

$products_array = array();

reset($this->contents);

while (list($products_id, ) = each($this->contents)) {

//MVS start - added v.vendors_id, v.vendors_name, and v.vendors_id = p.vendors_id

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_discount, p.products_cost, p.products_weight, p.products_tax_class_id, v.vendors_id, v.vendors_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_VENDORS . " v where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and v.vendors_id = p.vendors_id and pd.language_id = '" . (int)$languages_id . "'");

//MVS end

if ($products = tep_db_fetch_array($products_query)) {

$prid = $products['products_id'];

$products_price = $products['products_price'];

 

// Simple Price Break

if( isset($products['products_discount']) && strlen($products['products_discount'])>2 ) {

if( $tranche = explode( ',', $products['products_discount'] ) ) {

foreach( $tranche as $cle => $trn )

if( $qty_px = explode( ':', $trn ) ) {

if( $this->contents[$products_id]['qty'] >= $qty_px[0] )

$products_price = $qty_px[1];

}

}

}

// Simple Price Break

 

$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");

if (tep_db_num_rows($specials_query)) {

$specials = tep_db_fetch_array($specials_query);

if( $products_price > $specials['specials_new_products_price'] )

$products_price = $specials['specials_new_products_price'];

}

 

// BOF add-weight-to-product-attributes with UPSxml mod

 

// determine total weight of attributes to add to weight of product

$attributes_total_weight = 0;

 

if (isset($this->contents[$products_id]['attributes'])) {

 

reset($this->contents[$products_id]['attributes']);

 

$where = ' AND ((';

 

while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {

 

$where .= 'options_id=' . $option . ' AND options_values_id=' . $value . ') OR (';

 

}

 

$where=substr($where, 0, -5) . ')';

 

 

$attribute_weight_query = tep_db_query('SELECT options_values_weight FROM ' . TABLE_PRODUCTS_ATTRIBUTES . ' WHERE products_id=' . (int)$prid . $where);

 

 

if (tep_db_num_rows($attribute_weight_query)) {

 

while ($attributes_weight_array = tep_db_fetch_array($attribute_weight_query)) {

$attributes_total_weight += $attributes_weight_array['options_values_weight'];

 

}

 

} // end if (tep_db_num_rows($attribute_weight_query))

 

} // end if (isset($this->contents[$products_id]['attributes']))

 

// EOF add-weight-to-product-attributes mod

 

//clr 030714 update $products_array to include attribute value_text. This is needed for text attributes.

$products_array[] = array('id' => $products_id,

'name' => $products['products_name'],

'model' => $products['products_model'],

'image' => $products['products_image'],

'price' => $products_price,

'cost' => $products['products_cost'],

'quantity' => $this->contents[$products_id]['qty'],

'weight' => $products['products_weight'] + $attributes_total_weight,

'final_price' => ($products_price + $this->attributes_price($products_id)),

'tax_class_id' => $products['products_tax_class_id'],

//MVS start

'vendors_id' => $products['vendors_id'],

'vendors_name' => $products['vendors_name'],

//MVS end

'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''),

'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''));

 

}

}

 

return $products_array;

}

 

function show_total() {

$this->calculate();

 

return $this->total;

}

 

function show_weight() {

$this->calculate();

 

return $this->weight;

}

 

function generate_cart_id($length = 5) {

return tep_create_random_value($length, 'digits');

}

 

function get_content_type() {

$this->content_type = false;

 

if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) {

reset($this->contents);

while (list($products_id, ) = each($this->contents)) {

if (isset($this->contents[$products_id]['attributes'])) {

reset($this->contents[$products_id]['attributes']);

while (list(, $value) = each($this->contents[$products_id]['attributes'])) {

$virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$value . "' and pa.products_attributes_id = pad.products_attributes_id");

$virtual_check = tep_db_fetch_array($virtual_check_query);

 

if ($virtual_check['total'] > 0) {

switch ($this->content_type) {

case 'physical':

$this->content_type = 'mixed';

 

return $this->content_type;

break;

default:

$this->content_type = 'virtual';

break;

}

} else {

switch ($this->content_type) {

case 'virtual':

$this->content_type = 'mixed';

 

return $this->content_type;

break;

default:

$this->content_type = 'physical';

break;

}

}

}

} else {

switch ($this->content_type) {

case 'virtual':

$this->content_type = 'mixed';

 

return $this->content_type;

break;

default:

$this->content_type = 'physical';

break;

}

}

}

} else {

$this->content_type = 'physical';

}

 

return $this->content_type;

}

 

function unserialize($broken) {

for(reset($broken);$kv=each($broken) {

$key=$kv['key'];

if (gettype($this->$key)!="user function")

$this->$key=$kv['value'];

}

}

 

}

?>

Link to comment
Share on other sites

I'm not sure if anyone has had any luck with this but, i found some information on in this forum... http://www.oscommerce.com/forums/lofiversion/i...101973-350.html I tried to implement what they were talking about but i don't think i did it the right way. Would anyone be able to look at the information in that forum and let me know what i'm doing wrong? I've been plugging away at this for a few days now. Ugh.

 

The information in the forum start on Apr 17 2005, 11:24 PM by JSM.

 

Thanks - Mike C.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...