You can make discount code using Shopify API like
Step 1: Set Up a New Price Rule
POST /admin/api/2023-04/price_rules.json
{
"price_rule": {
"title": "15% Off on Orders Over $100",
"target_type": "line_item",
"target_selection": "all",
"allocation_method": "across",
"value_type": "percentage",
"value": "-15.0",
"customer_selection": "all",
"starts_at": "2024-11-01T00:00:00Z",
"prerequisite_subtotal_range": {
"greater_than_or_equal_to": "100.00"
}
}
}
Step 2:
Generate a Discount Code
POST /admin/api/2023-04/price_rules/{price_rule_id}/discount_codes.json
{
"discount_code": {
"code": "SAVE15"
}
}
you can make discount on other conditions as well as described here