1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
<?php
if (!function_exists('asa2_item_lookup')) {
/**
* Retrieves an ASA2 item object that contains the values of an Amazon product. This function takes the ASA2 Repo into consideration. If the requested item is already in the Repo, it will be loaded from there instead of the Amazon API.
*
* Example:
* ```php
* $item = asa2_item_lookup('B01M2AYHBV', array('country_code' => 'UK'));
*
* if (asa2_is_item_object($item)) {
* echo '<h3>' . $item->getTitle() . '</h3>';
* }
* ```
*
* @since 1.8.0
* @package API
*
* @param string $asin Amazon ASIN.
* @param array $options Optional.
* @return Asa2_Service_Amazon_Item_Wrapper_Abstract|null
*/
function asa2_item_lookup($asin, $options) {
if (class_exists('Asa2_Service')) {
return Asa2_Service::itemLookup($asin, $options);
}
}
}
if (!function_exists('asa2_item_batch_lookup')) {
/**
* Performs the Amazon API operation [ItemLookup](http://docs.aws.amazon.com/AWSECommerceService/latest/DG/ItemLookup.html) with support for multiple ASINs.
*
* Example:
* ```php
* $result = asa2_item_batch_lookup(array(
* array(
* 'asin' => 'B06Y5ZW72J',
* 'country_code' => 'UK'
* ),
* array(
* 'asin' => 'B01DOIFV12',
* 'country_code' => 'DE'
* )
* ));
*
* foreach ($result as $item) {
* if (asa2_is_item_object($item)) {
* echo '<h3>' . $item->getTitle() . '</h3>';
* }
* }
* ```
*
* @param array $batch The items for the lookup operation. See example above.
* @param array $options Optional. Options for the API lookup operation.
* @package API
* @return array|null Array of Asa2_Service_Amazon_Item_Wrapper_Abstract objects or null on error.
*/
function asa2_item_batch_lookup($batch, array $options = array()) {
if (class_exists('Asa2_Service')) {
return Asa2_Service::itemBatchLookup($batch, $options);
}
}
}
if (!function_exists('asa2_item_lookup_api')) {
/**
* Performs the Amazon API operation [ItemLookup](http://docs.aws.amazon.com/AWSECommerceService/latest/DG/ItemLookup.html). Will be removed with version 1.8.1
*
* Example:
* ```php
* $item = asa2_item_lookup_api('B01M2AYHBV', array('country_code' => 'UK'));
* if (asa2_is_item_object($item)) {
* echo '<h3>' . $item->getTitle() . '</h3>';
* }
* ```
* @since 1.8.0
* @package API
* @deprecated Use asa2_item_lookup instead which will get an additional parameter to force API request with the next update.
*
* @param string $asin Amazon ASIN.
* @param array $options Optional. Additional lookup parameters.
* @param bool $throwException Optional. Default: true. If set to true, throws a PHP exception on error.
* @return Asa2_Service_Amazon_Item_Wrapper_Abstract|null
*/
function asa2_item_lookup_api($asin, $options, $throwException = true) {
if (class_exists('Asa2_Service')) {
return Asa2_Service::itemLookupApi($asin, $options, $throwException);
}
}
}
if (!function_exists('asa2_item_search')) {
/**
* Performs the Amazon API operation [ItemSearch](http://docs.aws.amazon.com/AWSECommerceService/latest/DG/ItemSearch.html).
*
* Example:
* ```php
* $coffeeMakers = asa2_item_search('coffee makers');
* foreach ($coffeeMakers as $coffeeMaker) {
* if ($coffeeMaker instanceof Asa2_Service_Amazon_Item_Wrapper_Abstract) {
* echo '<h3>' . $coffeeMaker->getTitle() . '</h3>';
* }
* }
* ```
*
* @since 1.8.0
* @package API
*
* @param string $search The search string.
* @param array $options Optional. Search parameters.
* @param string $return Optional. Defines the return type. "response" returns an "Asa2_Service_Amazon_Response" object. Default is "resultset" which returns an "Asa2_Service_Amazon_Item_ResultSet" object which implements the SeekableIterator interface.
* @return Asa2_Service_Amazon_Item_ResultSet|Asa2_Service_Amazon_Response|null The defined return type object or null on error.
*/
function asa2_item_search($search, $options = array(), $return = 'resultset') {
if (class_exists('Asa2_Service')) {
return Asa2_Service::itemSearch($search, $options, $return);
}
}
}