Offer.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Service
  17. * @subpackage Amazon
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @category Zend
  24. * @package Zend_Service
  25. * @subpackage Amazon
  26. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  27. * @license http://framework.zend.com/license/new-bsd New BSD License
  28. */
  29. class Zend_Service_Amazon_Offer
  30. {
  31. /**
  32. * @var string
  33. */
  34. public $MerchantId;
  35. /**
  36. * @var string
  37. */
  38. public $MerchantName;
  39. /**
  40. * @var string
  41. */
  42. public $GlancePage;
  43. /**
  44. * @var string
  45. */
  46. public $Condition;
  47. /**
  48. * @var string
  49. */
  50. public $OfferListingId;
  51. /**
  52. * @var string
  53. */
  54. public $Price;
  55. /**
  56. * @var string
  57. */
  58. public $CurrencyCode;
  59. /**
  60. * @var string
  61. */
  62. public $Availability;
  63. /**
  64. * @var boolean
  65. */
  66. public $IsEligibleForSuperSaverShipping = false;
  67. /**
  68. * Parse the given Offer element
  69. *
  70. * @param DOMElement $dom
  71. * @return void
  72. */
  73. public function __construct(DOMElement $dom)
  74. {
  75. $xpath = new DOMXPath($dom->ownerDocument);
  76. $xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2011-08-01');
  77. $this->MerchantId = (string) $xpath->query('./az:Merchant/az:MerchantId/text()', $dom)->item(0)->data;
  78. $name = $xpath->query('./az:Merchant/az:Name/text()', $dom);
  79. if ($name->length == 1) {
  80. $this->MerchantName = (string) $name->item(0)->data;
  81. }
  82. $this->GlancePage = (string) $xpath->query('./az:Merchant/az:GlancePage/text()', $dom)->item(0)->data;
  83. $this->Condition = (string) $xpath->query('./az:OfferAttributes/az:Condition/text()', $dom)->item(0)->data;
  84. $this->OfferListingId = (string) $xpath->query('./az:OfferListing/az:OfferListingId/text()', $dom)->item(0)->data;
  85. $Price = $xpath->query('./az:OfferListing/az:Price/az:Amount', $dom);
  86. if ($Price->length == 1) {
  87. $this->Price = (int) $xpath->query('./az:OfferListing/az:Price/az:Amount/text()', $dom)->item(0)->data;
  88. $this->CurrencyCode = (string) $xpath->query('./az:OfferListing/az:Price/az:CurrencyCode/text()', $dom)->item(0)->data;
  89. }
  90. $availability = $xpath->query('./az:OfferListing/az:Availability/text()', $dom)->item(0);
  91. if($availability instanceof DOMText) {
  92. $this->Availability = (string) $availability->data;
  93. }
  94. $result = $xpath->query('./az:OfferListing/az:IsEligibleForSuperSaverShipping/text()', $dom);
  95. if ($result->length >= 1) {
  96. $this->IsEligibleForSuperSaverShipping = (bool) $result->item(0)->data;
  97. }
  98. }
  99. }