PHP Classes

File: src/examples/test.php

Recommend this page to a friend!
  Classes of The Algoslingers   Auto-Price   src/examples/test.php   Download  
File: src/examples/test.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Auto-Price
Adjust prices based on the current user location
Author: By
Last change:
Date: 1 month ago
Size: 442 bytes
 

Contents

Class file image Download
<?php
require 'vendor/autoload.php';

use
thealgoslingers\AutoPrice;

// Usage example
$api_key = 'your_api_key_here'; // api key from ip2location.io

// the default base price is approximately
// or same as 1 USD. So we assume price is
// being converted from USD
$base_price = 100.0;//base price to be converted from

$dp = new AutoPrice($api_key, $base_price);
$user_ip = '8.8.8.8';// ip of the user

echo $dp->calculatePrice($user_ip);