Need some one to fix a magento extension

Discussion in 'Programming' started by wounded1987, Nov 2, 2009.

  1. #1
    There is this magneto extension, and i want it fixed, it needs to be updated with new amazon api rules, and then be checked to make sure it works properly:

    <?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='99'");
                      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='567'");
                      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='567'");
                      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;
    }
    ?>
    PHP:
    please post me your price
     
    wounded1987, Nov 2, 2009 IP