Skip to content

Commit

Permalink
Added ISO country code
Browse files Browse the repository at this point in the history
fixing country code issues for pricing #12
  • Loading branch information
Luke Snowden authored and Luke Snowden committed Nov 13, 2017
1 parent d4ee8d5 commit 6e723fa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
29 changes: 22 additions & 7 deletions src/LukeSnowden/GoogleShoppingFeed/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,23 @@ class Feed
protected $namespace = 'http://base.google.com/ns/1.0';

/**
* [$version description]
* @var string
*/
protected $version = '2.0';

/**
* @var string
*/
protected $iso4217CountryCode = 'GBP';

/**
* Stores the list of items for the feed
* @var Item[]
*/
private $items = array();

/**
* [$channelCreated description]
* @var boolean
* @var bool
*/
private $channelCreated = false;

Expand All @@ -40,25 +43,21 @@ class Feed
private $feed = null;

/**
* [$title description]
* @var string
*/
private $title = '';

/**
* [$cacheDir description]
* @var string
*/
private $cacheDir = 'cache';

/**
* [$description description]
* @var string
*/
private $description = '';

/**
* [$link description]
* @var string
*/
private $link = '';
Expand Down Expand Up @@ -95,6 +94,22 @@ public function link($link)
$this->link = (string)$link;
}

/**
* @param $code
*/
public function setIso4217CountryCode( $code )
{
$this->iso4217CountryCode = $code;
}

/**
* @return string
*/
public function getIso4217CountryCode()
{
return $this->iso4217CountryCode;
}

/**
* [channel description]
*/
Expand Down
9 changes: 5 additions & 4 deletions src/LukeSnowden/GoogleShoppingFeed/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,15 @@ public function link($link)
}

/**
* [price - Set the price of the product, do not format before passing]
* @param [type] $price [description]
* @return [type] [description]
* price - Set the price of the product, do not format before passing
* @param $price
*/
public function price($price)
{
$node = new Node('price');
$this->nodes['price'] = $node->value(number_format($price, 2, '.', ''))->_namespace($this->namespace);
$price = number_format($price, 2, '.', '');
$code = GoogleShopping::getIso4217CountryCode();
$this->nodes['price'] = $node->value( $price . " {$code}" )->_namespace($this->namespace);
}

/**
Expand Down

0 comments on commit 6e723fa

Please sign in to comment.