หัวข้อ: คุณ numau109 และผู้รู้magento กับ amazon ครับช่วยหน่อย เริ่มหัวข้อโดย: krite2010 ที่ 12 เมษายน 2010, 21:02:58 <?php
/** * * AWS_Cart 0.0.1 - November 2008 * Copyright (C) awsfm.com * AWS_Cart is licensed under a Creative Commons License * */ include('config.php'); function priceCheck($id,$sku,$price,$type){ $request = "http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=ItemLookup&ItemId=$sku&ResponseGroup=Medium,Offers"; $session = curl_init($request); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); $response = file_get_contents($request); $parsed_xml = simplexml_load_string($response); $awsListPrice=$parsed_xml->Items->Item->ItemAttributes->ListPrice->FormattedPrice; $awsListPriceDB=substr_replace($parsed_xml->Items->Item->ItemAttributes->ListPrice->Amount, '.', -2, 0); $awsOfferListPrice=$parsed_xml->Items->Item->Offers->Offer->OfferListing->Price->FormattedPrice; $awsOfferListPriceDB=substr_replace($parsed_xml->Items->Item->Offers->Offer->OfferListing->Price->Amount, '.', -2, 0); if($type=='regular'){ if($awsListPrice!=$price){ $con = mysql_connect(dbhost,dbuser,dbpass); mysql_select_db(dbname,$con); mysql_query("UPDATE catalog_product_entity_decimal SET value=$awsListPriceDB WHERE entity_id=$id AND attribute_id='59'"); mysql_close($con); print $awsListPrice; }else{ print $price; } } if($type=='final'){ if($awsOfferListPrice!=$price){ $con = mysql_connect(dbhost,dbuser,dbpass); mysql_select_db(dbname,$con); mysql_query("UPDATE catalog_product_entity_decimal SET value=$awsOfferListPriceDB WHERE entity_id=$id AND attribute_id='60'"); mysql_close($con); print $awsOfferListPrice; }else{ print $price; } } } function priceCheckCheckout($id,$sku,$price){ $request = "http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=ItemLookup&ItemId=$sku&ResponseGroup=Medium,Offers"; $session = curl_init($request); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); $response = file_get_contents($request); $parsed_xml = simplexml_load_string($response); $awsListPrice=$parsed_xml->Items->Item->ItemAttributes->ListPrice->FormattedPrice; $awsListPriceDB=substr_replace($parsed_xml->Items->Item->ItemAttributes->ListPrice->Amount, '.', -2, 0); $awsOfferListPrice=$parsed_xml->Items->Item->Offers->Offer->OfferListing->Price->FormattedPrice; $awsOfferListPriceDB=substr_replace($parsed_xml->Items->Item->Offers->Offer->OfferListing->Price->Amount, '.', -2, 0); if($awsOfferListPrice!=$price){ $con = mysql_connect(dbhost,dbuser,dbpass); mysql_select_db(dbname,$con); mysql_query("UPDATE catalog_product_entity_decimal SET value=$awsOfferListPriceDB WHERE entity_id=$id AND attribute_id='60'"); mysql_close($con); } } function itemLookup($sku, $qty){ $request = "http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=ItemLookup&ItemId=$sku&ResponseGroup=Medium,Offers"; $session = curl_init($request); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); $response = file_get_contents($request); $parsed_xml = simplexml_load_string($response); $offerListingId = urlencode($parsed_xml->Items->Item->Offers->Offer->OfferListing->OfferListingId); cartCreate($offerListingId, $qty); } function cartCreate($offerListingId, $qty){ $request = "http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=CartCreate&Item.1.OfferListingId=$offerListingId&Item.1.Quantity=$qty"; $session = curl_init($request); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); $response = file_get_contents($request); $parsed_xml = simplexml_load_string($response); showCartContents($parsed_xml); } function itemLookupAdd($sku, $qty, $cart, $hmac){ $request = "http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=ItemLookup&ItemId=$sku&ResponseGroup=Medium,Offers"; $session = curl_init($request); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); $response = file_get_contents($request); $parsed_xml = simplexml_load_string($response); $offerListingId = urlencode($parsed_xml->Items->Item->Offers->Offer->OfferListing->OfferListingId); cartAdd($offerListingId, $qty, $cart, $hmac); } function cartAdd($offerListingId, $qty, $cart, $hmac){ $request="http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=CartAdd&CartId=$cart&HMAC=$hmac&Item.1.OfferListingId=$offerListingId&Item.1.Quantity=$qty"; $session = curl_init($request); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); $response = file_get_contents($request); $parsed_xml = simplexml_load_string($response); showCartContents($parsed_xml); } function showCartContents($parsed_xml){ global $checkout; global $CartId; global $HMAC; $checkout = $parsed_xml->Cart->PurchaseURL; $CartId = $parsed_xml->Cart->CartId; $HMAC = $parsed_xml->Cart->URLEncodedHMAC; } ?> คือ จาก code ข้างต้น ครับ ไม่ทราบว่า จะใส่หรืออ้างอิงตัวนี้อย่างไรครับ http://mierendo.com/software/aws_signed_query/ เนื่องจากไปพบ file นี้มาครับ http://www.magentocommerce.com/?ACT=25&fid=10&aid=9337_cvOqroEBGkb74dUtunkH&board_id=1 เลยไม่ทราบว่าจะแก้อย่างไร ใช้อย่างไรครับ ติดตั้งอย่างไรครับ แนะนำด้วย ขอบคุณครับ |