How can I dynamically retrieve a store name in a core PHP Shopify app?

Shopify Partner
2 0 0

Dear Support,

I trust this message finds you well.

I have successfully developed a Shopify app using core PHP. However, I am encountering an issue while running the install.php file—I am unable to retrieve the Shopify shop name.

Here is the code snippet I am currently using:


$dotenv = parse_ini_file('.env');

$shop = $_GET['shop'];
$api_key = $dotenv['API_KEY'];
$scopes = "read_orders,write_products,read_themes,write_themes";
$redirect_uri = $dotenv['REDIRECT_URI'];

// Build install/approval URL to redirect to
$install_url = "https://" . $shop . "" . $api_key . "&scope=" . $scopes . "&redirect_uri=" . urlencode($redirect_uri);

// Redirect
header("Location: " . $install_url);

While manually adding the shop name statically functions as expected, I am seeking guidance on dynamically obtaining the shop name. Could you kindly advise me on the appropriate approach to achieve this?

Thank you for your assistance.

Replies 0 (0)