Is it possible to apply discount by using checkout api in post method ?

DSLR
New Member
9 0 0

Hi everyone,

I'm currently create a checkout by using an checkout api in POST method and I'm planning to add 50% percent discount on overall list items .

I am tried to add apply discount argument on checkout data but it's not created discount . I am using this argument -

"applied_discount" => array("amount"=> "50.00",
"title"=> "Custom Discount",
"description"=> "custom discount",
"value"=> "50.00",
"value_type"=> "percentage",
"non_applicable_reason"=> null,
"applicable"=>'true',
),

 

It's give me this response - 

 

stdClass Object
(
    [checkout] => stdClass Object
        (
            [completed_at] => 
            [created_at] => 2021-02-03T11:03:49+01:00
            [currency] => EUR
            [presentment_currency] => CHF
            [customer_id] => 
            [customer_locale] => de
            [device_id] => 
            [discount_code] => 
            [email] => 
            [legal_notice_url] => 
            [location_id] => 
            [name] => #17424210034767
            [note] => 
            [note_attributes] => stdClass Object
                (
                    [Delivery Date] => 23-01-21
                )

            [order_id] => 
            [order_status_url] => 
            [order] => 
            [payment_due] => 16.17
            [payment_url] => https://deposit.us.shopifycs.com/sessions
            [payments] => Array
                (
                )

            [phone] => 
            [shopify_payments_account_id] => 
            [privacy_policy_url] => 
            [refund_policy_url] => 
            [requires_shipping] => 1
            [reservation_time_left] => 0
            [reservation_time] => 
            [source_identifier] => 
            [source_name] => my_app
            [source_url] => 
            [subscription_policy_url] => 
            [subtotal_price] => 16.17
            [shipping_policy_url] => 
            [tax_exempt] => 
            [taxes_included] => 1
            [terms_of_sale_url] => 
            [terms_of_service_url] => 
            [token] => 312366ab990f2694eed07de0f932b39f
            [total_price] => 16.17
            [total_tax] => 0.00
            [total_tip_received] => 0.00
            [total_line_items_price] => 16.17
            [updated_at] => 2021-02-03T11:03:49+01:00
            [user_id] => 
            [web_url] => "checkout url"
            [line_items] => Array
                (
                    [0] => stdClass Object
                        (
                            [id] => ba4a8571fd51262a268b90c4beeb06b9
                            [key] => ba4a8571fd51262a268b90c4beeb06b9
                            [product_id] => 4832881246287
                            [variant_id] => 32734407360591
                            [sku] => 
                            [vendor] => Volg
                            [title] => Test product
                            [variant_title] => 
                            [image_url] => https://cdn.shopify.com/s/files/1/0286/8998/9711/products/csm_promo_20809_de_2981abde0c.jpg?v=1605634812
                            [taxable] => 1
                            [requires_shipping] => 1
                            [gift_card] => 
                            [price] => 16.17
                            [compare_at_price] => 
                            [line_price] => 16.17
                            [properties] => stdClass Object
                                (
                                )

                            [quantity] => 1
                            [grams] => 360
                            [fulfillment_service] => manual
                            [applied_discounts] => Array
                                (
                                )

                            [tax_lines] => Array
                                (
                                )

                        )

                )

            [gift_cards] => Array
                (
                )

            [tax_lines] => Array
                (
                )

            [tax_manipulations] => Array
                (
                )

            [shipping_line] => 
            [shipping_rate] => 
            [shipping_address] => 
            [credit_card] => 
            [billing_address] => 
            [applied_discount] => 
        )

)

 

 

Please suggest me how we create it .

Thanks !

0 Likes