Jump to content


Corporate Sponsors


Latest News: (loading..)

ShaGGy

Member Since 24 Aug 2006
Offline Last Active Yesterday, 23:34
-----

Topics I've Started

Why is this not finding the results from the table ?

15 January 2012, 02:54

Can anyone see why the code below is returning an empty drop down box?
I have ran the query separately and it finds the results but the html_output part does not appear to be getting the values from the query. (this is a modified Countries selection box from within create_account.php)

general.php
  function tep_get_businesses($businesses_id = '') {
    $businesses_array = array();
    if (tep_not_null($businesses_id)) {
	    $businesses = tep_db_query("select business_id, business from " . TABLE_BUS_TYPE . " where active = 1 order by business");
  }
    return $businesses_array;
  }

general.php
  function tep_get_business_name($business_id) {
    $business_array = tep_get_businesses($business_id);

    return $business_array['business'];
  }

html_output.php
  function tep_get_business_list($name, $selected = '', $parameters = '') {
    $businesses_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
    $businesses = tep_get_businesses();

    for ($i=0, $n=sizeof($businesses); $i<$n; $i++) {
	  $businesses_array[] = array('id' => $businesses[$i]['business_id'], 'text' => $businesses[$i]['business']);
    }

    return tep_draw_pull_down_menu($name, $businesses_array, $selected, $parameters);
  }

create_account.php
		    <tr>
	    <td class="fieldKey"><?php echo ENTRY_BUS_TYPE; ?></td>
	    <td class="fieldValue"><?php echo tep_get_business_list('business') . '&nbsp;' . (tep_not_null(ENTRY_BUS_TYPE_TEXT) ? '<span class="inputRequirement">' . ENTRY_BUS_TYPE_TEXT . '</span>': ''); ?></td>
	  </tr>

Product Listing modifcation help needed

13 January 2012, 02:59

I am trying to make a customer history box where a customer can click it and get a list (similar to product_listing.php's output) where the customer can buy more of the same items they have purchased previously.

I have tried this query within product_info.php (with QPBB installed on 2.3.1) but keep getting no products


$bought_query = tep_db_query("select p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF( s.status, s.specials_new_products_price, NULL ) AS specials_new_products_price, IF( s.status, s.specials_new_products_price, p.products_price ) AS final_price FROM " . products_description . " pd, ". products . " p LEFT JOIN " . specials . " s ON p.products_id = s.products_id LEFT JOIN " . orders_products . " op ON op.products_id = p.products_id LEFT JOIN " . orders . " o ON op.orders_id = o.orders_id, " . products_to_categories . " p2c WHERE p.products_status = '1' AND p.products_id = p2c.products_id AND pd.products_id = p2c.products_id AND pd.language_id ='" . (int)$languages_id . "' AND o.customers_id ='" . (int)$customer_id ."'");

but if i insert this code within product_listing.php (moving the query to the top of the product_listing.php and altering the query name to match the one QPBB looks for) it gives the results (product_id & price & model)? (note you have to be logged in on a account that has sales history to get results)

<?php

require('includes/application_top.php');

$bought_query = tep_db_query("select p.products_id, p.manufacturers_id, p.products_price, p.products_model, p.products_tax_class_id, IF( s.status, s.specials_new_products_price, NULL ) AS specials_new_products_price, IF( s.status, s.specials_new_products_price, p.products_price ) AS final_price FROM " . products_description . " pd, ". products . " p LEFT JOIN " . specials . " s ON p.products_id = s.products_id LEFT JOIN " . orders_products . " op ON op.products_id = p.products_id LEFT JOIN " . orders . " o ON op.orders_id = o.orders_id, " . products_to_categories . " p2c WHERE p.products_status = '1' AND p.products_id = p2c.products_id AND pd.products_id = p2c.products_id AND pd.language_id ='" . (int)$languages_id . "' AND o.customers_id ='" . (int)$customer_id ."'");

// get the data
echo "<table border=1 cellpadding=5>";
echo "<tr><td>products_id</td><td>products_price</td><td>products_model</td></tr>";

while ( $categories = tep_db_fetch_array($bought_query) ) {

$cPath_new = tep_get_path($categories['products_id']);

echo "<tr><td>" . $categories ["products_id"] . "</td><td>" . $categories["products_price"] . "</td><td>" . $categories["products_model"] . "</td></tr>";

}

echo "</table>";

?>

does anyone know how I can get a copy of product_listing.php to display the results from the SQL query above?

Product Listing price Zero when item in cart help!

29 December 2011, 01:59

I have installed Quantity Price Breaks http://addons.oscommerce.com/info/8040 for 2.3.1 and all went fine, then i changed the Product_listing.php for a one from 2.3.1 as the one in the contrib had the OLD 2007 version.

everything is working fine then I add a quantity box into the product listing page which works as it should but now I have a weird problem that I cannot find a solution too.

What happens is when I ADD an item to the cart from product_listing the price displayed in product_listing becomes ZERO (the correct price is shown in the cart and checkout) it just loses the price on any item that is in the cart but only on the Product_listing page, if i add a second of the item in the cart (now showing £0.00 on product listing) it adds to the cart at the correct price?

So basically the price displayed in Product listing is correct until I had the item to cart which results in the displayed price becoming ZERO (but only what is displayed on screen as it carries the correct price to the cart if added) if I remove the item from the cart the price displayed on product list reverts back to what it should be.

I have checked all my currency settings etc are correct (besides it works okay from product_info).

Here is the code i have inserted into product_listing.php

		$no_of_listings = tep_db_num_rows($listing_query);
		while ($_listing = tep_db_fetch_array($listing_query)) {
		 $_listing['discount_categories_id'] = NULL;
		$listing[] = $_listing;
		$list_of_prdct_ids[] = $_listing['products_id'];
   }
   $list_of_prdct_ids = array_unique($list_of_prdct_ids);
		$price_breaks_query = tep_db_query("select products_id, products_special_price_2, products_qty from  " . TABLE_PRODUCTS . " where products_id in (" . implode(',', $list_of_prdct_ids) . ") order by products_id, products_qty");
		while ($price_break = tep_db_fetch_array($price_breaks_query)) {
				  $price_breaks_array[$price_break['products_id']][] = array('products_price' => $price_break['products_special_price_2'], 'products_qty' => $price_break['products_qty']);
		}
		$discount_category_query = tep_db_query("select p.products_id, p.products_quantity, p.products_weight, discount_categories_id from " . TABLE_PRODUCTS ." p left join " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " using(products_id) where p.products_id in (" . implode(',', $list_of_prdct_ids) . ")");
   while ($dc_array = tep_db_fetch_array($discount_category_query)) {
		 $discount_categories[] = array ('products_id' => $dc_array['products_id'], 'products_quantity' => $dc_array['products_quantity'], 'products_weight' => $dc_array['products_weight'], 'discount_categories_id' => $dc_array['discount_categories_id']);
   }
		for ($x = 0; $x < $no_of_listings; $x++) {
// add discount categories to the listing array
		  if(!empty($discount_categories)) {
				for ($i = 0; $i < count($discount_categories); $i++) {
				 if ($listing[$x]['products_id'] == $discount_categories[$i]['products_id'] ) {
				  $listing[$x]['discount_categories_id'] = $discount_categories[$i]['discount_categories_id'];
				  $listing[$x]['products_quantity'] = $discount_categories[$i]['products_quantity'];
				  $listing[$x]['products_weight'] = $discount_categories[$i]['products_weight'];
				}
		   }
		 } // end if(!empty($discount_categories)
   }
//	  while ($listing = tep_db_fetch_array($listing_query)) { (was original code)
for ($x = 0; $x < $no_of_listings; $x++) {
		  $rows++;

Code for displaying price in Product Listing

		 case 'PRODUCT_LIST_PRICE':
			$price_breaks_from_listing = array();		
  if (isset($price_breaks_array[$listing[$x]['products_id']])) {
  $price_breaks_from_listing = $price_breaks_array[$listing[$x]['products_id']];
}
			  if (tep_not_null($listing[$x]['specials_new_products_price'])) {
			  $prod_list_contents .= '		<td align="left"><del>' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</del>  <span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span></td>';
			  } else {		  
  
		$pf->loadProduct($listing[$x]['products_id'], $languages_id, $listing[$x], $price_breaks_from_listing);
			  $prod_list_contents .= '		<td align="right">' . $pf->getPriceStringshort() . '</td>';
	}
  break;

and for the button

case 'PRODUCT_LIST_BUY_NOW':
$prod_list_contents .= ' <td align="center">' . tep_draw_form('buy_now',tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'products_id')) . 'action=buy_now&products_id='. $listing[$x]['products_id']), 'POST') . '<input type="text" name="cart_quantity" value="1" maxlength="4" size="4">' . tep_draw_hidden_field('products_id', $listing[$x]['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary') . '</form></td>';
break;

Hope someone can help solve this as I am ripping my air out over it [img]http://forums.oscommerce.com//public/style_emoticons/default/smile.png[/img]

Multi Vendor Feed Manager Importer

26 November 2011, 21:32

Looking for a bit of help with this add on Multi Vendor Feed Manager Importer

I have got it installed and it is downloading the file from the FTP and placing it within the feeds dir but then I get an error Warning: Invalid argument supplied for foreach() in /home/xxxxxxxx/public_html/feed_import.php on line 118
DONE ::Row Count:: 0 ::Redirects:: 0

But line 118 in feed_import.php is a blank line ?

any suggestions as I really could do with getting this add on working.

thanks for any help in advance.