Sanjoy Roy

[MCM, MCP, SCJP] – Senior PHP Programmer

Tag Archives: osCommerce

oscommerce – 30 minutes cleanup from cart baskets


include_once("includes/configure.php");
$conn = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD);
mysql_select_db(DB_DATABASE);
$sql = "SELECT `customers_basket_id`,`customers_id`,`products_id`,`customers_basket_quantity`,`final_price`,`customers_basket_date_added`,`auction_product`,`customers_basket_datetime` FROM   `customers_basket` ORDER BY `customers_basket_id` ASC";
$result = mysql_query($sql);

while ($row = mysql_fetch_assoc($result)) {
	$products_id = $row["products_id"];
	$customers_id = $row["customers_id"];
	$customers_basket_quantity = $row["customers_basket_quantity"];	
	$total_minutes = 0;
	$customers_basket_datetime = $row["customers_basket_datetime"];
	$total_minutes = date_diff($customers_basket_datetime);
	if ($total_minutes >= 30){			
		$sql = "update products set products_quantity = products_quantity + ".$customers_basket_quantity." where products_id = '" .$products_id. "'";
		mysql_query($sql);
		//echo $sql."
"; $sql = "delete from customers_basket where customers_id = '" .$customers_id. "' AND products_id = '" .$products_id. "'"; mysql_query($sql); //echo $sql."
"; $products_parent_id = 0; $products_parent_id = tep_hasParentID($products_id); //echo 'products_parent_id: '.$products_parent_id."
"; if ($products_parent_id>0) { $sql = "update `products` set `products_quantity` = 0, `products_status` = 1 where `products_id` = '".$products_parent_id."'"; mysql_query($sql); //echo $sql."
"; } //echo "
"; } //echo "
"; } mysql_free_result($result); function tep_hasParentID($products_id) { global $conn; $prod_query = mysql_query("SELECT `products_parent_id` FROM `products` WHERE `products_id`='".$products_id."'"); $prods = mysql_fetch_array($prod_query); return $prods['products_parent_id']; } function date_diff($start, $end="NOW"){ $sdate = strtotime($start); $edate = strtotime($end); $time = $edate - $sdate; $phour = ($edate - $sdate) / 3600; $prehour = explode('.',$phour); $premin = $phour-$prehour[0]; $min = explode('.',$premin*60); $presec = '0.'.$min[1]; $sec = $presec*60; $total_mins = 0; if($prehour[0]>0) $total_mins = ($prehour[0] * 60) + $min[0]; else $total_mins = $min[0]; return $total_mins; }
Advertisements

creloaded 6.2 – osCommerce – shopping cart check/uncheck all – remove items from cart


HTML:
<input type="button" value="CHECK ALL" onclick="checkUncheck(true);" />&nbsp;<input type="button" value="UNCHECK ALL" onclick="checkUncheck(false);" />
JS:

function checkUncheck(flag) {
				  for (var i=0;i<document.forms[0].elements.length;i++) {
					var e = document.forms[0].elements[i];
					if ( (e.name != 'cart_delete') && (e.type=='checkbox') && (!e.disabled) ) {
					  if(flag) document.forms[0].elements[i].checked = true; else document.forms[0].elements[i].checked = false;
					}
				  }
				}

Creloaded 6.2 – osCommerce – Cross sell products


$categories = array();
$sql = "SELECT `categories_id` FROM `products_to_categories` WHERE `products_id` = '".$HTTP_GET_VARS['products_id']."'";
$result = tep_db_query($sql);
while ($row = mysql_fetch_assoc($result)) {
    $categories[] = $row["categories_id"];
}

$categories_str = '';
if (sizeof($categories)){
	$categories_str = implode("','", $categories);
}

$products = array();
$sql = "SELECT `products_id` FROM `products_to_categories` WHERE `categories_id` IN ('".$categories_str."')";
$result = tep_db_query($sql);
while ($row = mysql_fetch_assoc($result)) {
    $products[] = $row["products_id"];
}
$products_str = '';
if (sizeof($products)){
	$products_str = implode("','", $products);
}

//echo "'".$products_str."'
"; /*SELECT * FROM `products` w ORDER BY RAND() LIMIT 0 , 6;*/ $sql = "select distinct p.products_id, p.products_image, p.products_price, p.manufacturers_id, pd.products_name, p.products_tax_class_id, p.products_date_added, p.products_image , xp.xsell_id products_price from (" . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id), " . TABLE_PRODUCTS_XSELL . " xp, " . TABLE_PRODUCTS_DESCRIPTION . " pd where xp.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and p.products_id = xp.xsell_id and pd.products_id = xp.xsell_id and pd.language_id = '" . $languages_id . "' and p.products_status = '1' order by rand(), xp.products_id asc limit " . 6; //echo $sql.'
'; $sql = "SELECT * FROM `products` where products_id IN ('".$products_str."') AND `products_price` 0 ORDER BY RAND() LIMIT 0 , 6";

osCommerce – Vouchers or coupons when assigned to specific products


Filename: includes/modules/order_total/ot_coupon.php

$c_restrict_to_products 		= $coupon_result['restrict_to_products'];
$logs .= 'c_restrict_to_products: '.$c_restrict_to_products;	   
$c_restrict_to_categories 	= $coupon_result['restrict_to_categories'];
$logs .= 'c_restrict_to_categories: '.$c_restrict_to_categories;

$valid_coupon_product_id_exists = 'false';
if($c_restrict_to_products !=''){		    	  
  $db_product_ids = split("[,]", $c_restrict_to_products);		   
  for ($i=0; $i products); $i++) { 
	$logs .= 'products_id: '.$order->products[$i]['id'];
	if (in_array($order->products[$i]['id'], $db_product_ids)) {
		 $valid_coupon_product_id_exists = 'true';
	}
  }		  			  
}else if($c_restrict_to_categories !=''){
  $db_category_ids = split("[,]", $c_restrict_to_categories);
  for ($i=0; $i products); $i++) { 			
	$category_id = $this->getProductsCategoryID($order->products[$i]['id']);
	$logs .= 'products_id: '.$order->products[$i]['id'];
	$logs .= 'category_id: '.$category_id;
	if (in_array($category_id, $db_category_ids)) {
		 $valid_coupon_product_id_exists = 'true';
	}
  }  		 	  
}
$logs .= 'valid_coupon_product_id_exists: '.$valid_coupon_product_id_exists;
if ($valid_coupon_product_id_exists == 'false') {		    
  tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=ot_coupon&error=' . urlencode('This coupon is not valid for the product(s) you are purchasing.' ), 'SSL'));
}

function getProductsCategoryID($products_id){
$category_id 		= 0;
$p_parent_query		=	tep_db_query("select `products_parent_id` from `products` where products_id = '".$products_id."'");
$p_parent_result	=	tep_db_fetch_array($p_parent_query);
$products_parent_id = 	$p_parent_result['products_parent_id'];

if($products_parent_id == 0){
	$sql = "SELECT `categories_id` FROM `products_to_categories` where products_id = '".$products_id."'";
	$p_parent_queryX = tep_db_query($sql);
	$category_id = $p_parent_queryX['categories_id'];
}else{
	$sql = "SELECT `categories_id` FROM `products_to_categories` where products_id = '".$products_parent_id."'";
	$p_parent_queryY = tep_db_query($sql);	
	$category_id = $p_parent_queryY['categories_id'];
}
return $category_id;
}

Online shop e-commerce solution – osCommerce


osCommerce is an online shop e-commerce solution that offers a wide range of out-of-the-box features that allows online stores to be setup fairly quickly with ease, and is available for free as an Open Source based solution released under the GNU General Public License.

osCommerce was started in March 2000 and has since matured to a solution that is currently powering 11,826 registered live shops around the world.

Today, osCommerce has been taken to the next level, moving towards an e-commerce framework solution that not only remains easy to setup and maintain, but also making it easier for store administrators to present their stores to their customers with their own unique requirements.

Download Link is here.

%d bloggers like this: