Перейти к содержимому


Как добавить вес товара в корзину?


  • Вы не можете ответить в тему
В этой теме нет ответов

#1 vsupport

    Продвинутый пользователь

  • Администраторы
  • 758 сообщений
Репутация: 31
Ассистент

Отправлено 01 July 2011 - 02:20 PM

core\tpl\user\default\shopping_cart.tpl.html

после
{$smarty.const.TABLE_PRODUCT_QUANTITY}

вставляем
{$smarty.const.ADMIN_PRODUCT_WEIGHT}

перед
{$cart_content[i].cost}

вставляем
{$cart_content[i].weight}

а также для вывода общего веса перед


{$smarty.const.TABLE_TOTAL}

вставляем


Общий вес:

{$total_weight}

 


файл core\includes\shopping_cart.php

перед
$smarty->assign("cart_content", $resCart["cart_content"] );

вставляем
//пересчет веса

$total_weight = 0;

foreach($resCart["cart_content"] as $key => $pr_in_cart)

{

$resCart["cart_content"][$key]["weight"] = (int)$pr_in_cart["quantity"] * $pr_in_cart["weight"];

// общий вес

$total_weight += $resCart["cart_content"][$key]["weight"];

}

$smarty->assign("total_weight", $total_weight );

и последнее - файл core\functions\cart_functions.php

меняем функцию cartGetCartContent

на эту
function cartGetCartContent()

{

$cart_content = array();

$total_price = 0;

$freight_cost = 0;





if (isset($_SESSION["log"])) //get cart content from the database

{

$q = db_query("select itemID, Quantity FROM ".SHOPPING_CARTS_TABLE.

" WHERE customerID=".(int)regGetIdByLogin($_SESSION["log"]));



while ($cart_item = db_fetch_row($q))

{

// get variants

$variants=GetConfigurationByItemId( $cart_item["itemID"] );



// shopping cart item

$q_shopping_cart_item = db_query("select productID from ".

SHOPPING_CART_ITEMS_TABLE." where ".

" itemID=".(int)$cart_item["itemID"]);

$shopping_cart_item = db_fetch_row( $q_shopping_cart_item );

//////////////////////////

$q_products = db_query("select name, Price, productID, min_order_amount, shipping_freight, free_shipping, product_code, weight FROM ".

PRODUCTS_TABLE." WHERE productID=".(int)$shopping_cart_item["productID"]);

//////////////////////////////

if ( $product = db_fetch_row($q_products) )

{

$costUC = GetPriceProductWithOption( $variants,

$shopping_cart_item["productID"] );

$tmp =

array(

"productID" => $product["productID"],

"id" => $cart_item["itemID"],

"name" => $product["name"],

"quantity" => $cart_item["Quantity"],

"free_shipping" => $product["free_shipping"],

"costUC" => $costUC,

"cost" => show_price($cart_item["Quantity"]*

GetPriceProductWithOption($variants,

$shopping_cart_item["productID"])),

"product_code" => $product["product_code"],

//////////////////////////

"weight" => $product["weight"]);



$freight_cost += $cart_item["Quantity"]*$product["shipping_freight"];



$strOptions=GetStrOptions(

GetConfigurationByItemId( $tmp["id"] ));



if ( trim($strOptions) != "" )

$tmp["name"].=" (".$strOptions.")";





if ( $product["min_order_amount"] > $cart_item["Quantity"] )

$tmp["min_order_amount"] = $product["min_order_amount"];





$cart_content[] = $tmp;

$total_price += $cart_item["Quantity"]*

GetPriceProductWithOption($variants,

$shopping_cart_item["productID"]);



}

}

}

else //unauthorized user - get cart from session vars

{

$total_price = 0; //total cart value

$cart_content = array();





//shopping cart items count

if ( isset($_SESSION["gids"]) )

for ($j=0; $j
{

if ($_SESSION["gids"][$j])

{

$session_items[]=

CodeItemInClient($_SESSION["configurations"][$j],

$_SESSION["gids"][$j]);



////////////////

$q = db_query("select name, Price, shipping_freight, free_shipping, product_code, weight FROM ".

PRODUCTS_TABLE." WHERE productID=".(int)$_SESSION["gids"][$j]);

//////////////////////////

if ($r = db_fetch_row($q))

{

$costUC = GetPriceProductWithOption(

$_SESSION["configurations"][$j],

$_SESSION["gids"][$j])/* * $_SESSION["counts"][$j]*/;



$id = $_SESSION["gids"][$j];

if (count($_SESSION["configurations"][$j]) > 0)

{

for ($tmp1=0;$tmp1
}



$tmp = array(

"productID" => $_SESSION["gids"][$j],

"id" => $id, //$_SESSION["gids"][$j],

"name" => $r[0],

"quantity" => $_SESSION["counts"][$j],

"free_shipping" => $r["free_shipping"],

"costUC" => $costUC,

"cost" => show_price($costUC * $_SESSION["counts"][$j]),

"product_code" => $r["product_code"],

"weight" => $product["weight"]);



$strOptions=GetStrOptions( $_SESSION["configurations"][$j] );

if ( trim($strOptions) != "" )

$tmp["name"].=" (".$strOptions.")";





$q_product = db_query( "select min_order_amount, shipping_freight from ".PRODUCTS_TABLE.

" where productID=".

(int)$_SESSION["gids"][$j] );

$product = db_fetch_row( $q_product );

if ( $product["min_order_amount"] > $_SESSION["counts"][$j] )

$tmp["min_order_amount"] = $product["min_order_amount"];



$freight_cost += $_SESSION["counts"][$j]*$product["shipping_freight"];



$cart_content[] = $tmp;



$total_price += GetPriceProductWithOption(

$_SESSION["configurations"][$j],

$_SESSION["gids"][$j] )*$_SESSION["counts"][$j];

}

}

}

}



return array(

"cart_content" => $cart_content,

"total_price" => $total_price,

"freight_cost" => $freight_cost );



}

источник


  • 0