EIGHTEEN cool mods for ISC

For Articles relating to more than one ISC version
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

[mod] Product on hand in Order Quickview

Post by Snooper »

This mod will display the on hand quantity of a product on an order displayed next to the SKU in the Customers order quickview of the Admin panel. This is represented as a number in brackets, such as SKU1234 (5) where 5 is the quantity on hand. This mod is not for any product with variations unless a general total of stock is required.

Open \admin\includes\classes\class.remote.php

Find:
$prodFieldsArray=$GLOBALS['ISC_CLASS_ADMIN_ORDERS']->GetOrderProductFieldsData($orderId);

// Get the products in the order
$query = "
SELECT o.*, p.prodname


Replace: SELECT o.*, p.prodname
With: SELECT o.*, p.prodname, prodcurrentinv

Find:
while($pRow = $GLOBALS['ISC_CLASS_DB']->Fetch($pResult)) {
$sku = "";


Add below:
$oh = "";

Find:
$sku = "<br /><em>" . isc_html_escape($pRow['ordprodsku']) . "</em>";

Add below:
$oh = " &nbsp;&nbsp; (" . isc_html_escape($pRow['prodcurrentinv']) . ")";

Find:
".$pRow['ordprodname'].$sEnd.$sku.$pOptions."</td>

Replace with:
".$pRow['ordprodname'].$sEnd.$sku.$oh.$pOptions."</td>

Image
Last edited by Snooper on Sat Mar 24, 2012 5:21 am, edited 4 times in total.
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

Adding a tab menu to site

Post by Snooper »

I’m sure you have seen a number of sites that have just under the ‘Add to Cart’ a number of tabs that let you show extra text and whatever for customers. The problem I found was they are far to complex and never easy to install. So this left me thinking of a short cut solution. I must warn you in advance, it’s very basic, but is a good starting point and can be quickly improved.

This ‘mod’’ then assumes for each product on your site, you have NO information below ‘Add to Cart’ button, just white space !!

The javascript is simply a way to switch between <div>’s identified by the standard <div id= and made to be as flexible as your requirements. If want to add more tabs, simply append to the line - var ids=new Array('a1','a2','a3'); In this example I have used pointers a1 through a3. Save this as ‘tabs.js’ and save into the yoursite/javascript folder.

Code: Select all

var ids=new Array('a1','a2','a3');

function switchid(id){	
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
To keep a level of control if you are looking to match colours schemes with your own site, I have used CSS that you should append to your template style sheet.

Code: Select all

#centeredmenu {
   float:left;
   width:100%;
   background:#fff;
   border-bottom:2px solid #a92b5b;
   overflow:hidden;
   position:relative;
}
#centeredmenu ul {
   clear:left;
   float:left;
   list-style:none;
   margin:0;
   padding:0;
   position:relative;
   left:5%;
   text-align:center;
}
#centeredmenu ul li {
   display:block;
   float:left;
   list-style:none;
   margin:0;
   padding:0;
   position:relative;
}
#centeredmenu ul li a {
   display:block;
   margin:0 0 0 1px;
   padding:3px 10px;
   background:#ddd;
   color:#000;
   text-decoration:none;
   line-height:1.3em;
}
#centeredmenu ul li a:hover {
   background:#b4b4b4;
   color:#fff;
}
#centeredmenu ul li a.active,
#centeredmenu ul li a.active:hover {
   color:#fff;
   background:#000;
   font-weight:bold;
}

#centeredmenu ul li a:active {
   background:#b4b4b4;
   color:#fff;
}
The code that ‘holds’ the tabs together and places them to the correct position on site, is a <div calling from the CSS - <div id="centeredmenu". You place this within yoursite/yourtemplate/panels/ProductDetails.html under the line %%SNIPPET_ProductAddToCart%% totally overwriting whats already there, and replacing the removed code at the same time.

Code: Select all

<div id="centeredmenu" style="width:440px;"><ul>
    <li class="current"><a href="javascript:switchid('a1');">Page 1</a></li>
    <li><a href="javascript:switchid('a2');"">Page 2</a></li>
    <li><a href="javascript:switchid('a3');"">page 3</a></li>
</ul></div>
       <div id='a1'class="content" style="display:block;width:418px;height:82px;">
           This is page 1
	</div>

      <div id='a2' class="content"  style="display:none;width:418px;height:82px;">
           This is page 2
	</div>

     <div id='a3' class="content"  style="display:none;width:418px;height:82px;">
           This is page 3
	</div>
		%%GLOBAL_AddThisLink%%
		<br class="Clear" />
	</div>
</div>
Fianlly, add to the very top of ProductDetails.html the link between tabs.js and the code above -

Code: Select all

<script type="text/javascript" src="%%GLOBAL_AppPath%%/javascript/tabs.js"></script>
On my test site this looks like -
Image
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

[mod] Keep your customers on the page they buy from

Post by Snooper »

If it’s one thing I hate about shopping online, is how some sites throw you at the cart just to show you what you already know ! This is what happens with ISC and its bleeping rude !!

Keep your customer on the page they are buying from is by far, user friendly.

Go to /templates/__master/Snippets/ProductAddToCart.html
Find –

Code: Select all

	   <input type="hidden" name="variation_id" class="CartVariationId" value="" />
And place below this –

Code: Select all

      <input type="hidden" name="returnUrl" value="%%GLOBAL_CurrentProductLink%%" />
Now locate from includes/class.product.php
Find –

Code: Select all

// If there are product variations, set them up
                if($row['prodvariationid'] > 0) {
                    $this->SetupProductVariations();
                } 
And place above this –

Code: Select all

             $GLOBALS['CurrentProductLink'] = ProdLink($this->_prodname); 
Go to file \javascript\listmode.js

Find:

Code: Select all

 	else {
					window.location = config.ShopPath + "/cart.php";
				}
Change to:

Code: Select all

   else {
					window.location = " ";
            }
**** NOTE : If you use this mod you can not use any '-' or '/' symbols in your product discriptions. This may cause an error on page re-call. It is is how ISC was programmed and a stupid over sight....
Last edited by Snooper on Thu Mar 29, 2012 12:46 am, edited 3 times in total.
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

[mod] Shop by Brand Dropdown

Post by Snooper »

Here is a way to offer your customer base the option to pull from your site, any product by band (or common asset).

Go to folder includes/display and then add - SideShopByBrandDropdown.php

Code: Select all

<?php
/*

*/
CLASS ISC_SIDESHOPBYBRANDDROPDOWN_PANEL extends PANEL
	{
		public $cacheable = true;
		public $cacheId = "brands.sideshopbybranddropdown";
		
		function SetPanelSettings()
		{
			$output = "";

			// Get the number of brands
			$query = "select count(brandid) as num from [|PREFIX|]brands";
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			$row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
			$num_brands = $row['num'];
			$kwd_currentId = '';
			if(isset($GLOBALS['BrandId'])) {
				$kwd_currentId = $GLOBALS['BrandId'];
			}
			
			if($num_brands > 0) {
				// Get the list of brands
				$query = "select b.brandid, b.brandname, (select count(productid) from [|PREFIX|]products p where p.prodbrandid=b.brandid and p.prodvisible='1') as num from [|PREFIX|]brands b order by b.brandname asc";

				$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			
				while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
					$GLOBALS['BrandLink'] = BrandLink($row['brandname']);
					
					$kwd_Id = $row['brandid'];
					if($kwd_Id == $kwd_currentId)  {
						$GLOBALS['CurrentBrand'] = ' selected="selected"';
					} else {
						$GLOBALS['CurrentBrand'] = '';
					}
					$GLOBALS['BrandName'] = isc_html_escape($row['brandname']);
					$output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ShopByBrandDropdownItem");
				}

				$output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
				
				// Create a virtual snippet called %%SNIPPET_SideShopByBrandDropdown%% that contains all of the
				// brand options, not just one.
				$GLOBALS['SNIPPETS']['SideShopByBrandDropdown'] = $output;
			}
			else {
				// Hide the panel
				$this->DontDisplay = true;
				$GLOBALS['HideSideShopByBrandDropdownPanel'] = "none";
			}
		}
	}

?>
Now go to your site templates/your-template/Panels and add - SideShopByBrandDropdown.html

Code: Select all

<div class="Block AllBrands Moveable" style="display:%%GLOBAL_HideSideShopByBrandFullPanel%%" id="SideShopByBrandDropdown">
	<h2>%%LNG_AllBrands%%</h2>
	<div class="BlockContent">
		<form>
			<select id="brand" onchange="window.open(this.options[this.selectedIndex].value,'_self')">
				<option>Select a Brand</option>
				%%SNIPPET_SideShopByBrandDropdown%%
			</select>

			<noscript>
				<input type="submit" Value="Go" />
			</noscript>
		</form>
	</div>
</div>
Add to the front_language.ini file within /language folder the following - SeeAllBrands = "See all brands"

Now go to your site templates/your-template/Snippets and add - ShopByBrandDropdownItem.html

Code: Select all

<option value="%%GLOBAL_BrandLink%%"%%GLOBAL_CurrentBrand%%>%%GLOBAL_BrandName%%</option>
Activate by using - %%Panel.ShopByBrandDropdown%%

Image
Last edited by Snooper on Thu Mar 29, 2012 12:47 am, edited 13 times in total.
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

[mod] Add ‘Customers Also Purchased’ to the Cart Page

Post by Snooper »

The Interspire Shopping Cart has a “Customers Also Bought” feature, but for some reason, they didn’t think to make it functional on the cart page — one of the most useful (and obvious) places to have the feature. This modification will allow you to place the SideProductAlsoBought panel into your theme’s cart.html template, using the %%Panel.SideProductAlsoBought%% placeholder in the template.

Find the following code in /includes/display/SideProductAlsoBought.php -

Code: Select all

$query = "
	SELECT ordprodid
	FROM [|PREFIX|]order_products
	WHERE orderorderid IN (SELECT orderorderid FROM [|PREFIX|]order_products WHERE ordprodid='".$GLOBALS['ISC_CLASS_PRODUCT']->GetProductId()."') AND ordprodid != ".$GLOBALS['ISC_CLASS_PRODUCT']->GetProductId()."
	GROUP BY ordprodid
	ORDER BY COUNT(ordprodid) DESC
";
And replace it with this code -

Code: Select all

// Begin: Allow users also bought for recently added products
$OnlyRecentlyAdded = false; // make true to only show Also Bought for the product that was just added.

if(isset($GLOBALS['ISC_CLASS_CART'])) {
	if($OnlyRecentlyAdded && isset($_REQUEST['suggest'])) {
		$cartProduct = $GLOBALS['ISC_CLASS_CART']->api->GetProductInCart($_REQUEST['suggest']);
		if(is_array($cartProduct)) {
			$this->newCartItem = $_REQUEST['suggest'];
			$productId = $cartProduct['product_id'];
		}

		$queryIds[0] = " ordprodid='".$productId."'";
		$queryIds[1] = " ordprodid !=".$productId;

	} else {
		$cartProducts = $GLOBALS['ISC_CLASS_CART']->api->GetProductsInCart();
		if(is_array($cartProducts)) {
			foreach($cartProducts as $product) {
				$i++;
				if(!in_array($product['product_id'], $productIds)) {
					$productIds[] = $product['product_id'];
					$queryIds[0] .= ' ordprodid=\''.$product['product_id'].'\'';
					$queryIds[1] .= ' ordprodid != '.$product['product_id'];
				}
				if(isset($cartProducts[$i]) && !in_array($cartProducts[$i]['product_id'],$productIds)) {
					$queryIds[0] .= ' OR';
					$queryIds[1] .= ' AND';
				}
			}
		}
	}

} else {
	$queryIds[0] = " ordprodid='".$GLOBALS['ISC_CLASS_PRODUCT']->GetProductId()."'";
	$queryIds[1] = " ordprodid !=".$GLOBALS['ISC_CLASS_PRODUCT']->GetProductId();
}

$query = "
	SELECT ordprodid
	FROM [|PREFIX|]order_products
	WHERE orderorderid IN (SELECT orderorderid FROM [|PREFIX|]order_products WHERE".$queryIds[0].") AND".$queryIds[1]."
	GROUP BY ordprodid
	ORDER BY COUNT(ordprodid) DESC
";
// End: 
This adds a little load time to the cart.php page, but it will help cross-sell products.
Last edited by Snooper on Thu Mar 29, 2012 12:48 am, edited 2 times in total.
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

[mod] Edit products from within product page in admin..

Post by Snooper »

If when you are working on your site as administrator and you discover a product with an error, you now need to go all over the place to get to the relivant tool that used to correct this. Why cant you simply click over an “Edit Product” link ?

In includes/display/ProductDetails.php:

Find -

Code: Select all

$this->SetProductVariations();
Add this in a line below it:

Code: Select all

$this->SetEditProductLink();
Locate the last, closing curly bracket in the file } .... Remember the last !! You are placeing above this the following -

Code: Select all

/**
 * Create a link to allow users with permission to edit products from the products page
 */
public function SetEditProductLink()
{
	$GLOBALS['EditProductLink'] = '';
	if(!isset($GLOBALS['ISC_CLASS_ADMIN_AUTH'])) { $GLOBALS['ISC_CLASS_ADMIN_AUTH'] = GetClass('ISC_ADMIN_AUTH'); }
	if($GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Edit_Products)) {
		$GLOBALS['EditProductLink'] = sprintf('<a title="%3$s" class="Action" href="'.$GLOBALS['ShopPath'].'/admin/index.php?ToDo=editProduct&productId=%2$d">%1$s</a>', 'Edit Product', $GLOBALS['ProductId'], "Edit product ‘{$GLOBALS['ProductName']}’");
	}
}
Now the link will be generated in the global variable EditProductLink in your template’s ProductDetails panel.

Go to your template folder and find Panels/ProductDetails.html

Add -

Code: Select all

%%GLOBAL_EditProductLink%%
to your template where you want the link. to be located -
Image
Last edited by Snooper on Thu Mar 29, 2012 12:48 am, edited 2 times in total.
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

Search with smart redirection

Post by Snooper »

If your users are specific enough to type in an exact product name, brand name, product SKU or product ID, you better get them to the product they want, right away — they’re likely to buy!

I don’t want to show them a search results page, I want them to see the product or brand page itself. This script will redirect users if there’s a good reason to, which has to be the idea if -

= Exact product name match (case-insensitive)
= Exact product SKU match
= Exact product ID match
= “Good’nuf” product match: if there’s only one product result, and that result has a relevance score of 75 or above
= Exact brand name match (case-insensitive)

Open the class.products.php, found at includes/classes/class.products.php. Find the searchForItems() function (near line 1160), and above return $products; at the end of the function, insert the following code:

Code: Select all

/*
 * Begin Smart Search Redirection mod
 */
$redirect = false;

// Product redirect
foreach($products as $row) {
	if(	trim(strtolower($searchQuery['search_query'])) == trim(strtolower($row['prodcode'])) ||  // Query = SKU
		trim(strtolower($searchQuery['search_query'])) == trim(strtolower($row['productid'])) || // Query = Product ID
		trim(strtolower($searchQuery['search_query'])) == trim(strtolower($row['prodname'])) || // Query = Product Name
		$row['score'] > 75 && sizeof($products) == 1 // Relevance is good, and there's only one product result
	) {
		$redirect = ProdLink($row["prodname"]);
	}
}

if(empty($redirect)) {
	// Generate list of brand names
	foreach($products as $p) { $brands[] = $p['prodbrandid']; }
	$brandQuery = '"'.implode('" OR brandid="', array_unique($brands)).'"'; // Group brands by ID, generate query string
	$query = sprintf("select brandname from [|PREFIX|]brands where brandid=$brandQuery", $p['prodbrandid']);
	$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

	// Brand name match redirect
	while($brand = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
		if(trim(strtolower($searchQuery['search_query'])) == trim(strtolower($brand['brandname'])) && $redirect === false) {
			$redirect = BrandLink($brand["brandname"]);
		}
	}
}

// If there's a redirection found, do it up!
if(!empty($redirect)) {
	ob_end_clean();
	header("Location: $redirect");
	die();
}
/*
 * End Smart Search Redirection mod
 */
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

[mod] Preview your upload before it goes live

Post by Snooper »

ISC does not allow you to preview products that you are editing without making the product live in the store. This is plain silly; it’s vital for store owners to make sure their products pages look just as they expect when they make the product live in their store. As it is currently (in Interspire 5.5.x), this is not possible.

So lets' make this happen -

Firstly, find the following code in includes/classes/class.products.php near or around line 126 :

Code: Select all

$query = "
	SELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, pi.*, ".GetProdCustomerGroupPriceSQL().",
	(SELECT COUNT(fieldid) FROM [|PREFIX|]product_customfields WHERE fieldprodid=p.productid) AS numcustomfields,
	(SELECT COUNT(reviewid) FROM [|PREFIX|]reviews WHERE revstatus='1' AND revproductid=p.productid AND revstatus='1') AS numreviews,
	(SELECT brandname FROM [|PREFIX|]brands WHERE brandid=p.prodbrandid) AS prodbrandname,
	(SELECT COUNT(imageid) FROM [|PREFIX|]product_images WHERE imageprodid=p.productid) AS numimages,
	(SELECT COUNT(discountid) FROM [|PREFIX|]product_discounts WHERE discountprodid=p.productid) AS numbulkdiscounts
	FROM [|PREFIX|]products p
	LEFT JOIN [|PREFIX|]product_images pi ON (pi.imageisthumb=1 AND p.productid=pi.imageprodid)
	WHERE ".$productSQL." AND p.prodvisible='1'
";
And totally replace this with :

Code: Select all

$query = "
	SELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, pi.*, ".GetProdCustomerGroupPriceSQL().",
	(SELECT COUNT(fieldid) FROM [|PREFIX|]product_customfields WHERE fieldprodid=p.productid) AS numcustomfields,
	(SELECT COUNT(reviewid) FROM [|PREFIX|]reviews WHERE revstatus='1' AND revproductid=p.productid AND revstatus='1') AS numreviews,
	(SELECT brandname FROM [|PREFIX|]brands WHERE brandid=p.prodbrandid) AS prodbrandname,
	(SELECT COUNT(imageid) FROM [|PREFIX|]product_images WHERE imageprodid=p.productid) AS numimages,
	(SELECT COUNT(discountid) FROM [|PREFIX|]product_discounts WHERE discountprodid=p.productid) AS numbulkdiscounts
	FROM [|PREFIX|]products p
	LEFT JOIN [|PREFIX|]product_images pi ON (pi.imageisthumb=1 AND p.productid=pi.imageprodid)
	WHERE ".$productSQL."
";

	// Begin View Hidden Products Mod
	if(!isset($GLOBALS['ISC_CLASS_ADMIN_AUTH'])) { $GLOBALS['ISC_CLASS_ADMIN_AUTH'] = GetClass('ISC_ADMIN_AUTH'); }
	// If the user has product editing capability, they can see the product when it's not visible on live store.
	if(!$GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Edit_Products)) {
		$query .= " AND p.prodvisible='1'";
	}
	// End View Hidden Products Mod
Now, any user with the permission to edit products will be able to see products that are not visible to users in the store.
Last edited by Snooper on Thu Mar 29, 2012 12:49 am, edited 1 time in total.
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
Tony Barnes
Posts: 744
Joined: Thu Jun 18, 2009 8:59 am

Re: FOURTEEN cool mods for ISC

Post by Tony Barnes »

Hey Snooper - what happened you you not knowing much about PHP??? lol!

Some nice little additions here, might implement the smart search, makes a lot of sense
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

Re: FOURTEEN cool mods for ISC

Post by Snooper »

I have seen what you can do… Blimmin miles difference between abilities.. I’m a learner as of getting ISC and all I'm doing is showing here what I have added or will return to my site as I learn how to develop it.

That mod roll over I saw from the other place is impressive...
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
Post Reply