Post by speedingorange » Wed Mar 11, 2015 6:40 pm

Hi All,

I have a large store that I manage and currently show a checklist of "assurances" to the customer in a tick list format. With over 1000 products it is becoming a pain to manage.

I have thought up a solution to this to make it easier than manually entering each attribute at admin level and instead use attribute codes to determine what assurances should be displayed.

an example of the assurances would be as per the attached screenshot:
Capture.PNG

Capture.PNG (11.72 KiB) Viewed 540 times

I have put together a table that shows what codes should pull what messages:
Capture2.PNG

Capture2.PNG (16.32 KiB) Viewed 540 times

I have made the following modifications and the code works;
[disclaimer] This may be really wrong, I am not a coder (as is likely obvious) [/disclaimer]

in catalog/controller/product/product.php

after:

Code: Select all

			$data['reward'] = $product_info['reward'];
add:

Code: Select all

			$data['location'] = $product_info['location'];
Then in catalog/view/theme/template/product/product.php

add either of the following:

Code: Select all

<ul>
<?php if ($location == 111) { ?>
	<li>Free Shipping</li> 
	<li>1 Year Warranty</li>
<?php } else if ($location == 211) {?>
	<li>Free Next Day Shipping</li>
	<li>1 Year Warranty</li>
<?php } else if ($location == 121) {?>
	<li>Free Shipping</li>
	<li>2 Year Warranty</li>
<?php } else if ($location == 221) {?>
	<li>Free Next Day Shipping</li>
	<li>2 Year Warranty</li>
<?php } else if ($location == 112) {?>
	<li>Free Shipping</li>
	<li>1 Year Warranty</li>
	<li>Free Demonstration</li>
<?php } else if ($location == 122) {?>
	<li>Free Shipping</li>
	<li>2 Year Warranty</li>
	<li>Free Demonstration</li>
<?php } else if ($location == 212) {?>
	<li>Free Next Day Shipping</li>
	<li>1 Year Warranty</li>
	<li>Free Demonstration</li>
<?php } else if ($location == 222) {?>
	<li>Free Next Day Shipping</li>
	<li>2 Year Warranty</li>
	<li>Free Demonstration</li>
<?php } else if ($location == 160) {?>
	<li>Free Shipping</li>
	<li>6 Month Warranty</li>
<?php } else if ($location == 260) {?>
	<li>Free Next Day Shipping</li>
	<li>6 Month Warranty</li>
<?php } else {?>
	<li>Quality Products</li>
<?php} ?>
	<li>Secure Checkout</li>
</ul>
or

Code: Select all

<ul>
<?php switch ($location) { 
	case "111": echo "<li>Free Shipping</li><li>1 Year Warranty</li>"; break;
	case "211": echo	"<li>Free Next Day Shipping</li><li>1 Year Warranty</li>"; break;
	case "121": echo "<li>Free Shipping</li><li>2 Year Warranty</li>"; break;
	case "221": echo "<li>Free Next Day Shipping</li><li>2 Year Warranty</li>"; break;
	case "112": echo "<li>Free Shipping</li><li>1 Year Warranty</li><li>Free Demonstration</li>"; break;
	case "122": echo "<li>Free Shipping</li><li>2 Year Warranty</li><li>Free Demonstration</li>"; break;
	case "212": echo "<li>Free Next Day Shipping</li><li>1 Year Warranty</li><li>Free Demonstration</li>"; break;
	case "222": echo "<li>Free Next Day Shipping</li><li>2 Year Warranty</li><li>Free Demonstration</li>"; break;
	case "160": echo "<li>Free Shipping</li>	<li>6 Month Warranty</li>"; break;
	case "260": echo "<li>Free Next Day Shipping</li><li>6 Month Warranty</li>"; break;
	default: echo "<li>Quality Products</li>"; break;
} ?>
	<li>Secure Checkout</li>
</ul>

You can then enter any of the above location codes into the admin side of the cart (using a bulk editor) and the above list will display on the product page. (it obviously needs styling)

What I would like to know is if I am doing this the right way? is there a neater way of doing it? Is the switch method better than the else if method?

Many Thanks
James

Active Member

Posts

Joined
Tue Feb 23, 2010 7:33 pm
Who is online

Users browsing this forum: No registered users and 3 guests