ID,$asin_tag,true);
if (!$asin) { return false; } // we don't execute if the page does not have an asin
// get the remainder of the vars
$title = apply_filters('widget_title', $instance['title']);
$affiliate = apply_filters('widget_affiliate', $instance['affiliate']);
$widget_content = $this->getSingleAmazonProduct($asin,$affiliate);
// start the output
echo $before_widget;
if ( $title ) {
echo $before_title . $title . $after_title;
}
echo $widget_content;
echo $after_widget;
}
/** @see WP_Widget::update */
function update($new_instance, $old_instance) {
if (!$new_instance['affiliate']) {
$new_instance['affiliate'] = $this->affiliate;
}
if (!$new_instance['asin_tag']) {
$new_instance['asin_tag'] = $this->asin_tag;
}
return $new_instance;
}
// outputs the options form on admin
/** @see WP_Widget::form */
function form($instance) {
$title = esc_attr($instance['title']);
$affiliate = esc_attr($instance['affiliate']);
$asin_tag = esc_attr($instance['asin_tag']);
?>
The Amazon-Post-Purchase widget will only display on post pages.
To enable it's display for a Post, ensure that you:
set a custom field in your post with the same name indicated below, and
set the custom field value to the product's 10-digit ASIN code as provided by Amazon
* If not set, will default to our Affiliate ID
public_key;
$private_key = $this->private_key;
if (!$asin) { return false; }
$ASIN = $asin; //valid ASIN
$errors='';
// Amazon API Call
$pxml = aws_signed_request($aws_partner_locale, array(
"Operation"=>"ItemLookup",
"ItemId"=>"$ASIN",
"ResponseGroup"=>"ItemAttributes,Images,Offers",
"IdType"=>"ASIN",
"AssociateTag"=>"$aws_partner_id"), $public_key, $private_key);
//print_r($pxml);
if(isset($pxml["ItemLookupResponse"]["Items"]["Request"]["Errors"]["Error"]["Message"])){
$errors=$pxml["ItemLookupResponse"]["Items"]["Request"]["Errors"]["Error"]["Message"];
}
if($errors!=''){
// for now - errors are turned off and widget will not display
return false;
}
// get our result data formatted into a meaningful hash
$result = FormatASINResult($pxml);
// build up our HTML
// Test for a large image - if we have it, provide a link
$largeimage = false;
if($result['LargeImage']!=''){
$largeimage = <<< EOF