Create promo not making sense


#1

I had a look at your promotion setup and I am struggling to get to grips of it.

  1. When I look at your docs firstly it looks strange that I must GET to create a promo? must it not be POST?
 "schema": {
      "currencies": [
        {
          "currency": "USD",
          "amount": 900
        },
        {
          "currency": "GBP",
          "amount": 1100
        }
      ]
    }

in the docs you are expecting amount and currencies, but in the response I will get currency within currencies?


#2

Hi @handre,

With regards to question one, we have updated the docs as it was mistakenly marked as GET instead of POST

Can you clarify what you mean in question two, please?

Drew


#3

Hi @drew.

Thanks that makes a lot more sense.

In the docs the request must have schema(object), amount(sting), currencies(string).

so I would imagine that the response will be as follow:

schema{
             currencies: " ",
             amount: " ",
}

but your response in the docs are:

"schema": {
      "currencies": [
        {
          "currency": "USD",
          "amount": 900
        },
        {
          "currency": "GBP",
          "amount": 1100
        }
      ]
    },

#4

Hi @handre,

The POST request applies to more than one currency. So if you have a store with multiple currencies you can set the promotion amount for that currency.

In the developer docs (https://developers.moltin.com/guides/working-with-promotions#create-a-promotion) the following is included in the post request.

"schema": {
            "currencies": [
                {
                    "currency": "USD",
                    "percentage": 10
                },
                {
                    "currency": "GBP",
                    "percentage": 10
                }
            ]

If you specify more than one currency in the schema then more then one currency will be returned.

Hope this helps


#5

@drew

I think I am rather doing the promotion code route. Where do you set your discount price? in the docs under create discount code, it just asks for type, and codes. no percentage or anything like that ?


#6

Hi @handre

First you create your promotion as in the steps outlined here: https://developers.moltin.com/guides/working-with-promotions#create-a-promotion

The percentage amount is defined in the schema object posted to the API.

Once you have a promotion and the amount to deduct specified you can then attach the promotion codes to that promotion using the instructions outlined here: https://developers.moltin.com/guides/working-with-promotions#tie-promotion-code-s-to-the-promotion

Hope this helps


#7

@drew
ok so in the request you ask for a string of amount and currency. However the Schema is an object. So what does the object consist off?

because if it is the schema object is percent as shown:

 "schema": {
    "currencies": [
      {
        "currency": "GBP",
        "percentage": 12.5
      }
    ]
  }

surely the request does not need the currency and amount again?
Because now you are entering the amount and currency as a string, and then again in the schema object?


#8

Hi @handre I am not sure I follow, can you break it down into logical steps for me?


#9

@drew
I don’t know how to make it more logical.

in you docs you request the following:

name     string    A general name for the promotion.

description     string     A general description for the promotion.

type     string     The type should be promotion.

promotion_type     string     The type of schema being used for the promotion.  (fixed_discount or percent_discount)

enabled     string     True or False

start     string     The date at which the promotion starts.

end     string     The date at which the promotion ends.

amount     string     The amount off to be used for the promotion.

currencies     string     The Currency code to be used for the discount.

schema     object     The schema to be used for the promotion

BUT now the Schema option I want to use is the percent_discount. So that means I must replace the above mentioned schema object with this:

currencies     array     An array of objects

currencies[].currency     string     A currency code

currencies[].percentage     float     The percentage to discount by

IF my assumptions are correct and I replace the schema object with the schema option above. It asks currency and amount twice.

The problem lies with the schema object, is it just a open object, or do I replace it with the schema option I displayed above.

I hope you understand because I am not to sure how I will explain it better.


#10

@drew
I keep on getting this error?

detail: "Must validate one and only one schema (oneOf)"
source: "data"
status: 400
title: "number_one_of"

#11

Hi @handre

Sorry for the confusion we will endeavour to improve our documentation, are you able to show me the calls that produced the error above?


#12

@drew
I was able to figure it out. I would suggest in the create promotion docs, to take away amount and currency, and explain more in depth that the schema object can be found on the first page. Otherwise maybe show the different type of objects below the docs.


#13

Hey @handre! I’m working on some improvements to the promotions documentation now.

Thank you for your valuable feedback. Glad you got your issue ironed out :fist:


#14

@handre We just published some changes. Please let us know if this helps make things clearer for you. Appreciate any feedback!

https://docs.moltin.com/carts-and-checkout/promotions/create-promotion


#15

@jonathan
That changes would’ve saved me 2 days !

Makes a lot more sense.