Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

E-Commerce Modules /

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, Ed, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba

Multiple images per product


Go to End


10 Posts   6267 Views

Avatar
ccburns

Community Member, 79 Posts

1 October 2009 at 1:01am

Hi Guys,

Newbie to SilverStripe and to date loving everything. It's a bit for me to get my head around coming from more of a procedural background. But really like the work everyone has done, thanks.

Now I have installed the latest version of SS 2.3.3 with ecommerce-0.6-beta1 and payment-0.1-beta1 installed and everything is working really well. My client would like multiple images per product. Now I have seen a few posts about multiple images but none are really complete in terms of downloadable code for new people.

I haven't been able to get multiple images set up correctly so I thought I would ask for some help and then document it so that other can benefit as well.

Okay this one of the posts that has some suggestions with code snippets but I couldn't get it working.

[url=http://silverstripe.org/archive/show/7715?start=0]http://silverstripe.org/archive/show/7715?start=0

From this post I have interpreted as the following

Modify the ecommerce/code/Products/Product.php

<?php
/**
 * This is a standard Product page-type with fields like
 * Price, Weight, Model/Author and basic management of
 * groups.
 * 
 * It also has an associated Product_OrderItem class,
 * an extension of OrderItem, which is the mechanism
 * that links this page type class to the rest of the
 * eCommerce platform. This means you can add an instance
 * of this page type to the shopping cart.
 * 
 * @package ecommerce
 */
class Product extends Page {
	
	public static $db = array(
		'Price' => 'Currency',
		'Weight' => 'Decimal(9,2)',
		'Model' => 'Varchar',
		'FeaturedProduct' => 'Boolean',
		'AllowPurchase' => 'Boolean',
		'InternalItemID' => 'Varchar(30)'
	);
	
	static $has_one = array(
		'Image' => 'Product_Image',
		'TitleImage' => 'Image',
		'ThumbnailImage' => 'Image'
	);
	
	public static $has_many = array(
		'Variations' => 'ProductVariation',
		'ImageAttachment' => 'ImageAttachment'
	);
	
	public static $many_many = array(
		'ProductGroups' => 'ProductGroup'
	);
	
	public static $belongs_many_many = array();
	
	public static $defaults = array(
		'AllowPurchase' => true
	);
	
	public static $casting = array();
	
	static $default_parent = 'ProductGroup';
	
	static $add_action = 'a Product Page';
	
	static $icon = 'cms/images/treeicons/book';
	
	function getCMSFields() {
		$fields = parent::getCMSFields();

		// Standard product detail fields
		$fields->addFieldsToTab(
			'Root.Content.Main',
			array(
				new TextField('Weight', _t('Product.WEIGHT', 'Weight (kg)'), '', 12),
				new TextField('Price', _t('Product.PRICE', 'Price'), '', 12),
				new TextField('Model', _t('Product.MODEL', 'Model/Author'), '', 50),
				new TextField('InternalItemID', _t('Product.CODE', 'Product Code'), '', 7)
			)
		);

		if(!$fields->dataFieldByName('Image')) {
			$fields->addFieldToTab('Root.Content.Images', new ImageField('Image', _t('Product.IMAGE', 'Product Image')));
		}


		$imagetable = new HasManyComplexTableField(
			$this,
			'ImageAttachment', // relation name
			'ImageAttachment', // object class
            /*array(
             'Link' => 'Link',
             'ImageID' => 'Image'            
       ),
       'getCMSFields_forPopup'*/
			ImageAttachment::$field_names, // fields to show in table
			ImageAttachment::getCMSFields_forPopup(), // form that pops up for edit
            "ProductsID = {$this->ID}" // a filter to only display item associated with this page          
         );
		//$imagetable->setParentClass('Products');
		//$imagetable->setAddTitle( 'A Image' );
            
		$fields->addFieldToTab('Root.Content.RightPanelImage', $imagetable);

		// Flags for this product which affect it's behaviour on the site
		$fields->addFieldsToTab(
			'Root.Content.Main',
			array(
				new CheckboxField('FeaturedProduct', _t('Product.FEATURED', 'Featured Product')),
				new CheckboxField('AllowPurchase', _t('Product.ALLOWPURCHASE', 'Allow product to be purchased'), 1)
			)
		);

		$fields->addFieldsToTab(
			'Root.Content.Variations', 
			array(
				new HeaderField(_t('Product.VARIATIONSSET', 'This product has the following variations set')),
				new LiteralField('VariationsNote', '<p class="message good">If this product has active variations, the price of the product will be the price of the variation added by the member to the shopping cart.</p>'),
				$this->getVariationsTable()
			)
		);

		$fields->addFieldsToTab(
			'Root.Content.Product Groups',
			array(
				new HeaderField(_t('Product.ALSOAPPEARS', 'This product also appears in the following groups')),
				$this->getProductGroupsTable()
			)
		);
		
		return $fields;
	}
	
	function getVariationsTable() {
		$singleton = singleton('ProductVariation');
		$query = $singleton->buildVersionSQL("`ProductID` = '{$this->ID}'");
		$variations = $singleton->buildDataObjectSet($query->execute());
		$filter = $variations ? "`ID` IN ('" . implode("','", $variations->column('RecordID')) . "')" : "`ID` < '0'";
		//$filter = "`ProductID` = '{$this->ID}'";
		
		$tableField = new HasManyComplexTableField(
			$this,
			'Variations',
			'ProductVariation',
			array(
				'Title' => 'Title',
				'Price' => 'Price'
			),
			'getCMSFields_forPopup',
			$filter
		);
		
		if(method_exists($tableField, 'setRelationAutoSetting')) {
			$tableField->setRelationAutoSetting(true);
		}
		
		return $tableField;
	}
	
	protected function getProductGroupsTable() {
		$tableField = new ManyManyComplexTableField(
			$this,
			'ProductGroups',
			'ProductGroup',
			array(
				'Title' => 'Product Group Page Title'
			)
		);
		
		$tableField->setPageSize(30);
		$tableField->setPermissions(array());
		
		return $tableField;
	}
	
	/**
	 * Returns the shopping cart.
	 * @todo Does HTTP::set_cache_age() still need to be set here?
	 * 
	 * @return Order
	 */
	function Cart() {
		HTTP::set_cache_age(0);
		return ShoppingCart::current_order();
	}
	
	/**
	 * Conditions for whether a product can be purchased.
	 * 
	 * If it has the checkbox for 'Allow this product to be purchased',
	 * as well as having a price, it can be purchased. Otherwise a user
	 * can't buy it.
	 * 
	 * @return boolean
	 */
	function AllowPurchase() {
		return $this->AllowPurchase && $this->Price;
	}
	
	/**
	 * Returns if the product is already in the shopping cart.
	 * Note : This function is usable in the Product context because a
	 * Product_OrderItem only has a Product object in attribute
	 * 
	 * @return boolean
	 */
	function IsInCart() {
		return $this->Item() ? true : false;
	}
	
	/**
	 * Returns the order item which contains the product
	 * Note : This function is usable in the Product context because a
	 * Product_OrderItem only has a Product object in attribute
	 */
	function Item() {
		$currentOrder = ShoppingCart::current_order();
		if($items = $currentOrder->Items()) {
			foreach($items as $item) {
				if($item instanceof Product_OrderItem && $itemProduct = $item->Product()) {
					if($itemProduct->ID == $this->ID && $itemProduct->Version == $this->Version) return $item;
				}
			}
		}
	}
	
	/**
	 * Return the currency being used on the site.
	 * @return string Currency code, e.g. "NZD" or "USD"
	 */
	function Currency() {
		if(class_exists('Payment')) {
			return Payment::site_currency();
		}
	}
	
	/**
	 * Return the global tax information of the site.
	 * @return TaxModifier
	 */
	function TaxInfo() {
		$currentOrder = ShoppingCart::current_order();
		return $currentOrder->TaxInfo();
	}
	
	function addLink() {
		return $this->Link() . 'add';
	}

	function addVariationLink($id) {
		return $this->Link() . 'addVariation/' . $id;
	}
	
	/**
	 * When the ecommerce module is first installed, and db/build
	 * is invoked, create some default records in the database.
	 */
	function requireDefaultRecords() {
		parent::requireDefaultRecords();
		
		if(!DataObject::get_one('Product')) {		
			if(!DataObject::get_one('ProductGroup')) singleton('ProductGroup')->requireDefaultRecords();
			if($group = DataObject::get_one('ProductGroup', '', true, '`ParentID` DESC')) {
				$content = '<p>This is a <em>product</em>. It\'s description goes into the Content field as a standard SilverStripe page would have it\'s content. This is an ideal place to describe your product.</p>';
				
				$page1 = new Product();
				$page1->Title = 'Example product';
				$page1->Content = $content . '<p>You may also notice that we have checked it as a featured product and it will be displayed on the main Products page.</p>';
				$page1->URLSegment = 'example-product';
				$page1->ParentID = $group->ID;
				$page1->Price = '15.00';
				$page1->Weight = '0.50';
				$page1->Model = 'Joe Bloggs';
				$page1->FeaturedProduct = true;
				$page1->writeToStage('Stage');
				$page1->publish('Stage', 'Live');
				Database::alteration_message('Product page \'Example product\' created', 'created');
				
				$page2 = new Product();
				$page2->Title = 'Example product 2';
				$page2->Content = $content;
				$page2->URLSegment = 'example-product-2';
				$page2->ParentID = $group->ID;
				$page2->Price = '25.00';
				$page2->Weight = '1.2';
				$page2->Model = 'Jane Bloggs';
				$page2->writeToStage('Stage');
				$page2->publish('Stage', 'Live');
				Database::alteration_message('Product page \'Example product 2\' created', 'created');		
			}
		}
	}
	
}

class Product_Controller extends Page_Controller {
	
	function init() {
		parent::init();
		
		Requirements::themedCSS('Product');
		Requirements::themedCSS('Cart');
	}
	
	function add() {
		if($this->AllowPurchase() && $this->Variations()->Count() == 0) {
			ShoppingCart::add_new_item(new Product_OrderItem($this->dataRecord));
			if(!$this->isAjax()) Director::redirectBack();
		}
	}
	
	function ImageAttachment() {
      if($obj = DataObject::get('ImageAttachment', "ProductID = $this->ID")) {
         return $obj;
      } else {
         return false;
      }
   }
   
	function addVariation() {
		if($this->AllowPurchase && $this->urlParams['ID']) {
			$variation = DataObject::get_one(
				'ProductVariation', 
				sprintf(
					"`ID` = %d AND `ProductID` = %d",
					(int)$this->urlParams['ID'],
					(int)$this->ID
				)
			);
			if($variation) {
				if($variation->AllowPurchase()) {
					ShoppingCart::add_new_item(new ProductVariation_OrderItem($variation));
					if(!$this->isAjax()) Director::redirectBack();
				}
			}
		}
	}
	
}
class Product_Image extends Image {

	public static $db = array();
	
	public static $has_one = array();
	
	public static $has_many = array();
	
	public static $many_many = array();
	
	public static $belongs_many_many = array();
	
	function generateThumbnail($gd) {
		$gd->setQuality(80);
		return $gd->paddedResize(140,100);
	}
	
	function generateContentImage($gd) {
		$gd->setQuality(90);
		return $gd->resizeByWidth(200);
	}
	
	function generateLargeImage($gd) {
		$gd->setQuality(90);
		return $gd->resizeByWidth(600);
	}
	
}
class Product_OrderItem extends OrderItem {
	
	protected $_productID;
	
	protected $_productVersion;
	
	static $db = array(
		'ProductVersion' => 'Int'
	);
	
	static $has_one = array(
		'Product' => 'Product'
	);
	
	public function __construct($product = null, $quantity = 1) {
		// Case 1: Constructed by getting OrderItem from DB
		if(is_array($product)) {
			$this->ProductID = $this->_productID = $product['ProductID'];
			$this->ProductVersion = $this->_productVersion = $product['ProductVersion'];
		}
		
		// Case 2: Constructed in memory
		if(is_object($product)) {		
			$this->_productID = $product->ID;
 			$this->_productVersion = $product->Version;
 			
		}
		
 		parent::__construct($product, $quantity);
	}
	
	function getProductID() {
		return $this->_productID;
	}
	
	/**
	 * Overloaded Product accessor method.
	 *  
	 * Overloaded from the default has_one accessor to
	 * retrieve a product by it's version, this is extremely
	 * useful because we can set in stone the version of
	 * a product at the time when the user adds the item to
	 * their cart, so if the CMS admin changes the price, it
	 * remains the same for this order.
	 * 
	 * @param boolean $current If set to TRUE, returns the latest published version of the Product,
	 * 								If set to FALSE, returns the set version number of the Product
	 * 						 		(instead of the latest published version)
	 * @return Product object
	 */
	public function Product($current = false) {
		if($current) return DataObject::get_by_id('Product', $this->_productID);
		else return Versioned::get_version('Product', $this->_productID, $this->_productVersion);
	}
	
	function hasSameContent($orderItem) {
		$equals = parent::hasSameContent($orderItem);
		return $equals && $orderItem instanceof Product_OrderItem && $this->_productID == $orderItem->_productID && $this->_productVersion == $orderItem->_productVersion;
	}
	
	function UnitPrice() {
		return $this->Product()->Price;
	}
	
	function TableTitle() {
		return $this->Product()->Title;
	}

	function Link() {
		if($product = $this->Product(true)) return $product->Link();
	}
	
	function addLink() {
		return ShoppingCart_Controller::add_item_link($this->_productID);
	}
	
	function removeLink() {
		return ShoppingCart_Controller::remove_item_link($this->_productID);
	}
	
	function removeallLink() {
		return ShoppingCart_Controller::remove_all_item_link($this->_productID);
	}
	
	function setquantityLink() {
		return ShoppingCart_Controller::set_quantity_item_link($this->_productID);
	}

	function onBeforeWrite() {
		parent::onBeforeWrite();

		$this->ProductID = $this->_productID;
		$this->ProductVersion = $this->_productVersion;
	}
	
	public function debug() {
		$title = $this->TableTitle();
		$productID = $this->_productID;
		$productVersion = $this->_productVersion;
		return parent::debug() .<<<HTML
			<h3>Product_OrderItem class details</h3>
			<p>
				<b>Title : </b>$title<br/>
				<b>Product ID : </b>$productID<br/>
				<b>Product Version : </b>$productVersion
			</p>
HTML;
	}
}
?>

Then create a new file ecommerce/code/ImageAttachment.php

<?php
class ImageAttachment extends DataObject {
	static $db = array(
		'Name' => 'Text'
	);

	static $has_one = array(
		'Image' => 'Resize_Image',
		'Product' => 'Product'
	);

	static $field_names = array('Name' => 'Name');

	function getCMSFields_forPopup() {
		$fields = new FieldSet();
		$fields->push(new TextField('Name', 'Name'));
		$fields->push(new ImageField('Image', 'Image'));
		return $fields;
	}
}

class Resize_Image extends Image {
	
	static $db = null;

	function generateThumbnail($gd) {
		$gd->setQuality(80);
		return $gd->paddedResize(140,100);
	}

	function generateContentImage($gd) {
		$gd->setQuality(90);
		return $gd->resizeByWidth(200);
	}

	function generateLargeImage($gd) {
		$gd->setQuality(90);
		return $gd->resizeByWidth(600);
	}
}
?>

This code allows me to /db/build without error, but then when I log into the Admin section I see an additional tab for "Right Panel Image" which allows me to go through the process of uploading an image, but the actual image is not saved.

Also old tab called "Images" has a reference to a broken page.

I know this is a lot of code, sorry for that.

Firstly I don't know if I have implemented the suggestions correctly (obviously not). So if anyone has any pointers that would be great.

Kind Regards,
Colin

Avatar
dhensby

Community Member, 253 Posts

1 October 2009 at 2:46am

Hi ccburns,

Looks like a complex job. I haven't had time to analyse all of it, but your image class looks a little different to what i'd expect.

Is that definately working? Heres an example of an image class i created:

class myImage extends Image {
	
	public function UpTo($width) {
		return $this->getFormattedImage('UpTo', $width);
	}
	
	function generateUpTo(GD $gd, $dim) {
		if ($this->getWidth() > $dim || $this->getHeight() > $dim)
		{
			if ($this->getWidth() > $this->getHeight())
			{
				return $gd->resizeByWidth($dim);
			}
			else
			{
				return $gd->resizeByHeight($dim);
			}
		}
		else
		{
			return $gd;
		}
		return $gd->paddedResize($width, $height);
	}
}

You will notice i have a Classname() and generateClassname() function.

It's interesting that you have got the ecommerce module working. I've been trying to and can't get the shipping calculator to work. Does yours? If so, do you have an example _config.php i can look at or just some advise on how you got it working would be amazing.

Thanks.

Avatar
ccburns

Community Member, 79 Posts

1 October 2009 at 10:17am

Hi Pigeon,

No my site up is DEFINITELY NOT working. Things kind of show up in the admin interface, but the images are not being saved etc. I wanted to use this thread to get a definitive set of files so that:

1. I get the multiple images per product working like I need
2. It will be here in full code for others if they need it

I will swap out my image class for yours and let you know how I go.

Cheers,
Colin

Avatar
ccburns

Community Member, 79 Posts

1 October 2009 at 10:41am

BTW with regard to my shopping requirements. Mine are pretty simple for this particular client. If shipped within Australia the cost is included in the price but an country outside of Australia the shipping cost is $10.

So basically I created an array in the /payments/_config.php file

 // Set the cost of postage to different countries
SimpleShippingModifier::set_charges_for_countries(array(
		'AD' => 10,
		'AE' => 10,
		'AF' => 10,
		'AG' => 10,
		'AI' => 10,
		'AL' => 10,
		'AM' => 10,
		'AN' => 10,
		'AO' => 10,
		'AP' => 10,
		'AQ' => 10,
		'AR' => 10,
		'AS' => 10,
		'AT' => 10,
		'AU' => 0,
		'AW' => 10,
		'AZ' => 10,
		'BA' => 10,
		'BB' => 10,
		'BD' => 10,
		'BE' => 10,
		'BF' => 10,
		'BG' => 10,
		'BH' => 10,
		'BI' => 10,
		'BJ' => 10,
		'BM' => 10,
		'BN' => 10,
		'BO' => 10,
		'BR' => 10,
		'BS' => 10,
		'BT' => 10,
		'BV' => 10,
		'BW' => 10,
		'BY' => 10,
		'BZ' => 10,
		'CA' => 10,
		'CC' => 10,
		'CF' => 10,
		'CG' => 10,
		'CH' => 10,
		'CI' => 10,
		'CK' => 10,
		'CL' => 10,
		'CM' => 10,
		'CN' => 10,
		'CO' => 10,
		'CR' => 10,
		'CU' => 10,
		'CV' => 10,
		'CX' => 10,
		'CY' => 10,
		'CZ' => 10,
		'DE' => 10,
		'DJ' => 10,
		'DK' => 10,
		'DM' => 10,
		'DO' => 10,
		'DZ' => 10,
		'EC' => 10,
		'EE' => 10,
		'EG' => 10,
		'EH' => 10,
		'ER' => 10,
		'ES' => 10,
		'ET' => 10,
		'EU' => 10,
		'FI' => 10,
		'FJ' => 10,
		'FK' => 10,
		'FM' => 10,
		'FO' => 10,
		'FR' => 10,
		'FX' => 10,
		'GA' => 10,
		'GB' => 10,
		'GD' => 10,
		'GE' => 10,
		'GF' => 10,
		'GH' => 10,
		'GI' => 10,
		'GL' => 10,
		'GM' => 10,
		'GN' => 10,
		'GP' => 10,
		'GQ' => 10,
		'GR' => 10,
		'GS' => 10,
		'GT' => 10,
		'GU' => 10,
		'GW' => 10,
		'GY' => 10,
		'HK' => 10,
		'HM' => 10,
		'HN' => 10,
		'HR' => 10,
		'HT' => 10,
		'HU' => 10,
		'ID' => 10,
		'IE' => 10,
		'IL' => 10,
		'IN' => 10,
		'IO' => 10,
		'IQ' => 10,
		'IR' => 10,
		'IS' => 10,
		'IT' => 10,
		'JM' => 10,
		'JO' => 10,
		'JP' => 10,
		'KE' => 10,
		'KG' => 10,
		'KH' => 10,
		'KI' => 10,
		'KM' => 10,
		'KN' => 10,
		'KP' => 10,
		'KR' => 10,
		'KW' => 10,
		'KY' => 10,
		'KZ' => 10,
		'LA' => 10,
		'LB' => 10,
		'LC' => 10,
		'LI' => 10,
		'LK' => 10,
		'LR' => 10,
		'LS' => 10,
		'LT' => 10,
		'LU' => 10,
		'LV' => 10,
		'LY' => 10,
		'MA' => 10,
		'MC' => 10,
		'MD' => 10,
		'MG' => 10,
		'MH' => 10,
		'MK' => 10,
		'ML' => 10,
		'MM' => 10,
		'MN' => 10,
		'MO' => 10,
		'MP' => 10,
		'MQ' => 10,
		'MR' => 10,
		'MS' => 10,
		'MT' => 10,
		'MU' => 10,
		'MV' => 10,
		'MW' => 10,
		'MX' => 10,
		'MY' => 10,
		'MZ' => 10,
		'NA' => 10,
		'NC' => 10,
		'NE' => 10,
		'NF' => 10,
		'NG' => 10,
		'NI' => 10,
		'NL' => 10,
		'NO' => 10,
		'NP' => 10,
		'NR' => 10,
		'NU' => 10,
		'NZ' => 10,
		'OM' => 10,
		'PA' => 10,
		'PE' => 10,
		'PF' => 10,
		'PG' => 10,
		'PH' => 10,
		'PK' => 10,
		'PL' => 10,
		'PM' => 10,
		'PN' => 10,
		'PR' => 10,
		'PS' => 10,
		'PT' => 10,
		'PW' => 10,
		'PY' => 10,
		'QA' => 10,
		'RE' => 10,
		'RO' => 10,
		'RU' => 10,
		'RW' => 10,
		'SA' => 10,
		'SB' => 10,
		'SC' => 10,
		'SD' => 10,
		'SE' => 10,
		'SG' => 10,
		'SH' => 10,
		'SI' => 10,
		'SJ' => 10,
		'SK' => 10,
		'SL' => 10,
		'SM' => 10,
		'SN' => 10,
		'SO' => 10,
		'SR' => 10,
		'ST' => 10,
		'SV' => 10,
		'SY' => 10,
		'SZ' => 10,
		'TC' => 10,
		'TD' => 10,
		'TF' => 10,
		'TG' => 10,
		'TH' => 10,
		'TJ' => 10,
		'TK' => 10,
		'TL' => 10,
		'TM' => 10,
		'TN' => 10,
		'TO' => 10,
		'TR' => 10,
		'TT' => 10,
		'TV' => 10,
		'TW' => 10,
		'TZ' => 10,
		'UA' => 10,
		'UG' => 10,
		'UM' => 10,
		'US' => 10,
		'UY' => 10,
		'UZ' => 10,
		'VA' => 10,
		'VC' => 10,
		'VE' => 10,
		'VG' => 10,
		'VI' => 10,
		'VN' => 10,
		'VU' => 10,
		'WF' => 10,
		'WS' => 10,
		'YE' => 10,
		'YT' => 10,
		'YU' => 10,
		'ZA' => 10,
		'ZM' => 10,
		'ZR' => 10,
		'ZW' => 10
)); 

There is probably a way that is better than this, but this way all countries get a shipping cost. I had to do the same for Tax, which again in my case in inclusive of the price.

// Set the applicable Taxes
TaxModifier::set_for_country('AU', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('AD', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('AE', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('AF', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('AG', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('AI', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('AL', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('AM', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('AN', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('AO', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('AP', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('AQ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('AR', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('AS', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('AT', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('AW', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('AZ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BA', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BB', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BD', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BE', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BF', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BG', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BH', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BI', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BJ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BM', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BN', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BO', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BR', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BS', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BT', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BV', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BW', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BY', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('BZ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('CA', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('CC', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('CF', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('CG', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('CH', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('CI', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('CK', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('CL', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('CM', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('CN', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('CO', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('CR', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('CU', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('CV', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('CX', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('CY', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('CZ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('DE', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('DJ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('DK', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('DM', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('DO', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('DZ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('EC', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('EE', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('EG', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('EH', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('ER', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('ES', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('ET', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('EU', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('FI', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('FJ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('FK', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('FM', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('FO', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('FR', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('FX', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GA', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GB', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GD', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GE', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GF', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GH', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GI', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GL', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GM', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GN', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GP', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GQ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GR', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GS', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GT', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GU', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GW', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('GY', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('HK', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('HM', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('HN', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('HR', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('HT', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('HU', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('ID', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('IE', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('IL', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('IN', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('IO', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('IQ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('IR', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('IS', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('IT', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('JM', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('JO', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('JP', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('KE', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('KG', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('KH', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('KI', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('KM', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('KN', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('KP', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('KR', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('KW', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('KY', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('KZ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('LA', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('LB', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('LC', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('LI', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('LK', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('LR', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('LS', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('LT', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('LU', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('LV', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('LY', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MA', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MC', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MD', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MG', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MH', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MK', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('ML', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MM', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MN', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MO', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MP', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MQ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MR', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MS', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MT', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MU', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MV', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MW', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MX', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MY', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('MZ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('NA', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('NC', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('NE', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('NF', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('NG', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('NI', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('NL', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('NO', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('NP', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('NR', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('NU', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('NZ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('OM', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('PA', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('PE', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('PF', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('PG', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('PH', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('PK', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('PL', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('PM', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('PN', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('PR', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('PS', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('PT', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('PW', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('PY', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('QA', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('RE', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('RO', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('RU', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('RW', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SA', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SB', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SC', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SD', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SE', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SG', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SH', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SI', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SJ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SK', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SL', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SM', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SN', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SO', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SR', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('ST', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SV', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SY', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('SZ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('TC', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('TD', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('TF', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('TG', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('TH', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('TJ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('TK', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('TL', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('TM', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('TN', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('TO', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('TR', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('TT', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('TV', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('TW', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('TZ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('UA', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('UG', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('UM', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('US', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('UY', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('UZ', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('VA', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('VC', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('VE', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('VG', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('VI', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('VN', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('VU', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('WF', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('WS', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('YE', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('YT', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('YU', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('ZA', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('ZM', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('ZR', 0.10, 'GST', 'inclusive');
TaxModifier::set_for_country('ZW', 0.10, 'GST', 'inclusive');

This is probably the going the long way about it, but if I only set the TAX for Australia if someone wants it shipped to North America then it will take the tax out of it. Which is not the case. I believe if I am selling something in Australia I have to pay GST regardless of the location it is purchased from. Although I am not 100% certain of this...

Anyway, that's how I go the shipping & the tax to work.

Cheers,
Colin

Avatar
bubaphex

Community Member, 12 Posts

5 October 2009 at 1:37pm

Hi guys,

how you going with this? i've currently picked up a client who's currently needing this feature added to her store too, did you manage to fix all the bugs ?

Avatar
ccburns

Community Member, 79 Posts

5 October 2009 at 2:04pm

Still no luck at this point. I have tried a few things, but just haven't been able to crack it.

When I do, I will update the post.

If anyone else knows how to do this details instructions would be awesome ;)

Cheers

Avatar
Webdoc

Community Member, 349 Posts

6 October 2009 at 5:44am

Edited: 09/10/2009 1:31pm

Can someone please post the final working multiple image files in here.
so that its showing multiple image only in product information page

Do someone have then the working code

Avatar
Webdoc

Community Member, 349 Posts

9 October 2009 at 1:32pm

if somone have it ca u share it please

Go to Top