• 1.
     
  • 2.
     
  • 3.
    function affiliate_link() {	
  • 4.
     
  • 5.
    	// IP Geolocation	
  • 6.
    	$country_code = $_SERVER ["HTTP_CF_IPCOUNTRY"];
  • 7.
    	$de_asin = get_post_meta(get_post()->ID, "wccaf_de_asin", true );
  • 8.
    	$uk_asin = get_post_meta(get_post()->ID, "wccaf_uk_asin", true );
  • 9.
    	$fr_asin = get_post_meta(get_post()->ID, "wccaf_fr_asin", true );
  • 10.
    	$it_asin = get_post_meta(get_post()->ID, "wccaf_it_asin", true );
  • 11.
    	$es_asin = get_post_meta(get_post()->ID, "wccaf_es_asin", true );
  • 12.
    	$us_asin= get_post_meta(get_post()->ID, "wccaf_us_asin", true );
  • 13.
     
  • 14.
     
  • 15.
    //////////////////////////////////////////////
  • 16.
     
  • 17.
     
  • 18.
    if ($country_code=="DE" or $country_code=="DE" or $country_code=="AT" or $country_code=="CH" or $country_code=="LI" or $country_code=="EG") {
  • 19.
    	$amazon_domain = 'https://www.amazon.de';
  • 20.
    	$associate_id = 'bonstato-21';
  • 21.
    	$asin = $de_asin;
  • 22.
    }
  • 23.
     
  • 24.
    else if ($country_code=="GB" && $uk_asin!=="") {
  • 25.
    	$amazon_domain = 'https://www.amazon.co.uk';
  • 26.
    	$associate_id = 'bonmedico-21';
  • 27.
    	$asin = $uk_asin;
  • 28.
    }
  • 29.
     
  • 30.
    else if ($country_code=="FR" or $country_code=="LU" or $country_code=="BE" && $fr_asin!=="") {
  • 31.
    	$amazon_domain = 'https://www.amazon.fr';
  • 32.
    	$associate_id = 'bonmedico0b-21';
  • 33.
    	$asin = $fr_asin;
  • 34.
    }
  • 35.
     
  • 36.
    else if ($country_code=="IT" && $it_asin!=="") {
  • 37.
    	$amazon_domain = 'https://www.amazon.it';
  • 38.
    	$associate_id = 'bonmedico01-21';
  • 39.
    	$asin = $it_asin;
  • 40.
    }
  • 41.
     
  • 42.
    else if ($country_code=="ES" && $es_asin!=="") {
  • 43.
    	$amazon_domain = 'https://www.amazon.es';
  • 44.
    	$associate_id = 'bonmedico0f-21';
  • 45.
    	$asin = $es_asin;
  • 46.
    }
  • 47.
     
  • 48.
    else if ($country_code=="US" && $us_asin!=="") {
  • 49.
    	$amazon_domain = 'https://www.amazon.com';
  • 50.
    	$associate_id = 'bonstato-20';
  • 51.
    	$asin = $us_asin;
  • 52.
    }
  • 53.
     
  • 54.
    else if ($uk_asin!=="") {
  • 55.
    	$amazon_domain = 'https://www.amazon.co.uk';
  • 56.
    	$associate_id = 'bonmedico-21';
  • 57.
    	$asin = $uk_asin;
  • 58.
    }
  • 59.
    	
  • 60.
     
  • 61.
    ///////////////////////////////////////////////
  • 62.
     
  • 63.
     
  • 64.
    		// Get Amazon Button Title	
  • 65.
    if (ICL_LANGUAGE_CODE == "de") {
  • 66.
    	$amz_btn_title = 'Kaufen auf Amazon'; 
  • 67.
    }
  • 68.
    if (ICL_LANGUAGE_CODE == "en")	{
  • 69.
    	$amz_btn_title = 'Buy on Amazon'; 
  • 70.
    }
  • 71.
     
  • 72.
     
  • 73.
    // Product Type Identification		
  • 74.
     if(is_product()){
  • 75.
            global $post;
  • 76.
            $post_id = $post->ID;
  • 77.
            $product = wc_get_product( $post_id );
  • 78.
            $type = $product->get_type();
  • 79.
            if( $type == 'simple' && $asin!="" ){	
  • 80.
    		if( wp_is_mobile() ) {
  • 81.
     
  • 82.
    			// Amazon Link For Mobile		
  • 83.
    			?>
  • 84.
    			<script>
  • 85.
    				function amzGo(){
  • 86.
    							 window.location='<?php echo $amazon_domain ?>/dp/<?php echo $asin ?>/?tag=<?php echo $associate_id ?>';
  • 87.
    			  }
  • 88.
    			</script>
  • 89.
    			<?php
  • 90.
    		}
  • 91.
    		
  • 92.
    		else {	
  • 93.
    		// Amazon Link For PC
  • 94.
    			?>
  • 95.
    		<script>
  • 96.
    			function amzGo(){
  • 97.
    				window.location='<?php echo $amazon_domain ?>/gp/aws/cart/add.html?AssociateTag=<?php echo $associate_id ?>&ASIN.1=<?php echo $asin ?>&Quantity.1=1';
  • 98.
    		  }
  • 99.
    		</script>
  • 100.
    		<?php
  • 101.
    		}
  • 102.
     
  • 103.
     
  • 104.
    		?>
  • 105.
    			 <div class="buy_amz_btn_wrap" >  
  • 106.
    				<button type="button" id="buy_amz_btn" class="buy_amz_btn" onclick="amzGo();"><i class="fa fa-amazon fa-amz"></i><?php echo $amz_btn_title ?></button> 	  		 		 		 
  • 107.
    			</div>
  • 108.
    		<?php
  • 109.
     
  • 110.
    		}
  • 111.
     
  • 112.
    		 else {
  • 113.
    			 echo $not_avilable_country;
  • 114.
    		 }
  • 115.
     
  • 116.
    }
  • 117.
     
  • 118.
    }
  • 119.
     
function affiliate_link() { // IP Geolocation $country_code = $_SERVER ["HTTP_CF_IPCOUNTRY"]; $de_asin = get_post_meta(get_post()->ID, "wccaf_de_asin", true ); $uk_asin = get_post_meta(get_post()->ID, "wccaf_uk_asin", true ); $fr_asin = get_post_meta(get_post()->ID, "wccaf_fr_asin", true ); $it_asin = get_post_meta(get_post()->ID, "wccaf_it_asin", true ); $es_asin = get_post_meta(get_post()->ID, "wccaf_es_asin", true ); $us_asin= get_post_meta(get_post()->ID, "wccaf_us_asin", true ); ////////////////////////////////////////////// if ($country_code=="DE" or $country_code=="DE" or $country_code=="AT" or $country_code=="CH" or $country_code=="LI" or $country_code=="EG") { $amazon_domain = 'https://www.amazon.de'; $associate_id = 'bonstato-21'; $asin = $de_asin; } else if ($country_code=="GB" && $uk_asin!=="") { $amazon_domain = 'https://www.amazon.co.uk'; $associate_id = 'bonmedico-21'; $asin = $uk_asin; } else if ($country_code=="FR" or $country_code=="LU" or $country_code=="BE" && $fr_asin!=="") { $amazon_domain = 'https://www.amazon.fr'; $associate_id = 'bonmedico0b-21'; $asin = $fr_asin; } else if ($country_code=="IT" && $it_asin!=="") { $amazon_domain = 'https://www.amazon.it'; $associate_id = 'bonmedico01-21'; $asin = $it_asin; } else if ($country_code=="ES" && $es_asin!=="") { $amazon_domain = 'https://www.amazon.es'; $associate_id = 'bonmedico0f-21'; $asin = $es_asin; } else if ($country_code=="US" && $us_asin!=="") { $amazon_domain = 'https://www.amazon.com'; $associate_id = 'bonstato-20'; $asin = $us_asin; } else if ($uk_asin!=="") { $amazon_domain = 'https://www.amazon.co.uk'; $associate_id = 'bonmedico-21'; $asin = $uk_asin; } /////////////////////////////////////////////// // Get Amazon Button Title if (ICL_LANGUAGE_CODE == "de") { $amz_btn_title = 'Kaufen auf Amazon'; } if (ICL_LANGUAGE_CODE == "en") { $amz_btn_title = 'Buy on Amazon'; } // Product Type Identification if(is_product()){ global $post; $post_id = $post->ID; $product = wc_get_product( $post_id ); $type = $product->get_type(); if( $type == 'simple' && $asin!="" ){ if( wp_is_mobile() ) { // Amazon Link For Mobile ?> <script> function amzGo(){ window.location='<?php echo $amazon_domain ?>/dp/<?php echo $asin ?>/?tag=<?php echo $associate_id ?>'; } </script> <?php } else { // Amazon Link For PC ?> <script> function amzGo(){ window.location='<?php echo $amazon_domain ?>/gp/aws/cart/add.html?AssociateTag=<?php echo $associate_id ?>&ASIN.1=<?php echo $asin ?>&Quantity.1=1'; } </script> <?php } ?> <div class="buy_amz_btn_wrap" > <button type="button" id="buy_amz_btn" class="buy_amz_btn" onclick="amzGo();"><i class="fa fa-amazon fa-amz"></i><?php echo $amz_btn_title ?></button> </div> <?php } else { echo $not_avilable_country; } } }

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter