New Shopify Certification now available: Liquid Storefronts for Theme Developers

How can I create a simple Price Rule

able36
Tourist
14 0 5

I want to create a simple Price Rule to offer $50 coupons on a specific collection.

 

Is there a step by step tutorial for non-devs to create a Price Rule?

Reply 1 (1)
Saso-WD
Shopify Partner
21 0 8

Not sure which language you're using but in PHP it would be something like this:

use Shopify\Clients\Rest;
$client = new Rest("your-development-store.myshopify.com", $accessToken);
$response = $client->post(
"price_rules",
[
"price_rule" => [
"title" => "YOURDISCOUNTTITLE",
"target_type" => "line_item",
"target_selection" => "entitled",
"allocation_method" => "across",
"value_type" => "fixed_amount",
"value" => "-50.0",
"customer_selection" => "all",
"starts_at" => "2017-01-19T17:59:10Z",
"entitled_collection_ids" => [
0=>1234325435 //collection id
]
]
]
);