Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Cannot get product quantity from cart


monito

Recommended Posts

Posted

I'm trying to get the product quantity in the cart, but I always get a 0...

 

The quantities in cart are correct, but not in this function

 

Thanks in advance,

 

Monito

 

Here is the code

<?php

 

function calculate_credit($amount) {

global $order, $customer_id, $cart;

.

.

.

 

$query = tep_db_query("select entry_company from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . $customer_id . "'");

$query_result2 = tep_db_fetch_array($query);

 

$query = tep_db_query("select member_flag from " . TABLE_CUSTOMERS . " where customers_id = '" . $customer_id . "'");

$query_result = tep_db_fetch_array($query);

 

$member_estates_disc = 0.00;

if ($query_result['member_flag'] == '1') {

$products = $cart->get_products();

for ($i=0; $i<sizeof($products); $i++) {

$t_prid = tep_get_prid($products[$i]['id']);

 

// ++ begin: here is my problem (always 0)

$qty = $cart->get_quantity($t_prid);

// -- end

if (($t_prid == 10) || ($t_prid == 30) || ($t_prid == 153) || ($t_prid == 88)) {

$member_estates_disc = $member_estates_disc + (2.00 * $qty);

}

}

.

.

.

?>

Posted
		 $products = $cart->get_products();   //here you're reading in the whole products array - so you could just use it

	 for ($i=0; $i<sizeof($products); $i++) {

	   $t_prid = tep_get_prid($products[$i]['id']);

// ++ begin: here is my problem (always 0)
	   //$qty = $cart->get_quantity($t_prid);


//try this:
	   $qty = $products[$i]['quantity'];


// -- end

Contributions

 

Discount Coupon Codes

Donations

Archived

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

×
×
  • Create New...