Giter Club home page Giter Club logo

shopify-demo's Introduction

Create new discount code using Shopify API

Create a new discount rule

curl -X POST -H 'Content-Type: application/json' 'https://key:[email protected]/admin/price_rules.json' -d '{ "price_rule": { "title": "SUMMERSALE10OFF", "target_type": "line_item", "target_selection": "all", "allocation_method": "across", "value_type": "fixed_amount", "value": "-10.0", "customer_selection": "all", "starts_at": "2018-05-02T17:59:10Z" }}'

New discount rule response:

{"price_rule":{"id":279307124787,"value_type":"fixed_amount","value":"-10.0","customer_selection":"all","target_type":"line_item","target_selection":"all","allocation_method":"across","once_per_customer":false,"usage_limit":null,"starts_at":"2018-05-02T13:59:10-04:00","ends_at":null,"created_at":"2018-05-03T09:31:50-04:00","updated_at":"2018-05-03T09:31:50-04:00","entitled_product_ids":[],"entitled_variant_ids":[],"entitled_collection_ids":[],"entitled_country_ids":[],"prerequisite_saved_search_ids":[],"prerequisite_customer_ids":[],"prerequisite_subtotal_range":null,"prerequisite_quantity_range":null,"prerequisite_shipping_price_range":null,"title":"SUMMERSALE10OFF"}}

Use the new rule and create a new discount code:

curl -X POST -H 'Content-Type: application/json' 'https://key:[email protected]//admin/price_rules/279307124787/discount_codes.json' -d '{"discount_code": { "code": "SUMMERSALE10OFF" }}'

New discount code response:

{"discount_code":{"id":1200153198643,"price_rule_id":279307124787,"code":"SUMMERSALE10OFF","usage_count":0,"created_at":"2018-05-03T09:35:24-04:00","updated_at":"2018-05-03T09:35:24-04:00"}}

Finally, include the new discount code in an email link

https://aryeh-berkowitz.myshopify.com/discount/SUMMERSALE10OFF

shopify-demo's People

Contributors

berkoab avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.