How to use shopping cart buttons on domains other than domain where aMember is installed

From aMember Pro Documentation
Jump to: navigation, search

Add this code to site.php file:

/**
 * list of domains where you want to use shopping cart buttons
 * one domain per line
 */
$list = <<<CUT
example.com
www.example.com
CUT;
 
if (isset($_SERVER['HTTP_ORIGIN'])) {
    $origin = $_SERVER['HTTP_ORIGIN'];
    $host = parse_url($origin, PHP_URL_HOST);
    if (in_array($host, explode("\n", $list))) {
        header("Access-Control-Allow-Origin: $origin");
        header("Access-Control-Allow-Credentials: true");
    }
}