phplaravelshopify-appshopify-apiscopes

Shopify Laravel app: [API] This action requires merchant approval for write_price_rules scope. Where to set scopes in my shopify app with laravel?


I am developing an laravel app using shopify cli. I have use many api until now, but now when I want to create a price rules it is throwing an error "[API] This action requires merchant approval for write_price_rules scope.". I have already add this scope AppServiceProvider.php

Context::initialize(
            env('SHOPIFY_API_KEY', ''),
            env('SHOPIFY_API_SECRET', ''),
            env('SCOPES', 'write_price_rules,write_products,read_customers,read_price_rules,write_charges,read_products,products'),
            $host,
            new DbSessionStorage(),
            ApiVersion::LATEST,
            true,
            false,
            null,
            '',
            null,
            (array)$customDomain,
        );

and in DBSessionStorage.php in storeSession function like this $dbSession->scope = "write_price_rules,write_products,read_customers,write_charges,read_products,products"; I have tried to delete my db and install app but it is not working 😒

I was waiting to perform this api same as for read and write product api, but it is not working and I am not finding any good answer for that


Solution

  • I managed to fix that by adding Context::initialize into both register and boot function in AppServiceProvider and in .toml file in main directory.