Support

Home Forums Event Espresso Premium Create Ticket with API. TKT_price is set but not visible on EE Admin UI

Create Ticket with API. TKT_price is set but not visible on EE Admin UI

Posted: August 15, 2019 at 10:49 pm


Daniel

August 15, 2019 at 10:49 pm

I created a ticket using the API.

curl -X POST -H "Authorization: Bearer token_here" -d "TKT_name=All+Sessions-api-4&TKT_start_date=2019-09-28T16:49:46&TKT_end_date=2019-09-28T19:49:46&TKT_price=399.00&TKT_qty=10&TKT_required=true" "https://tasny.site/wp-json/ee/v4.8.36/tickets"

This creates the ticket. I see this data:


{
"TKT_ID": 29,
"TTM_ID": 0,
"TKT_name": "All Sessions-api-4",
"TKT_description": {
"raw": "",
"rendered": ""
},
"TKT_start_date": "2019-09-28T16:49:46",
"TKT_end_date": "2019-09-28T19:49:46",
"TKT_min": 0,
"TKT_max": null,
"TKT_price": {
"raw": 399,
"pretty": "$399.00 <span class=\"currency-code\">(USD)</span>"
},
"TKT_sold": 0,
"TKT_qty": 10,
"TKT_reserved": 0,
"TKT_uses": null,
"TKT_required": true,
"TKT_taxable": false,
"TKT_is_default": false,
"TKT_order": 0,
"TKT_row": 0,
"TKT_deleted": false,
"TKT_wp_user": 1,
"TKT_parent": 0,
"TKT_start_date_gmt": "2019-09-28T20:49:46",
"TKT_end_date_gmt": "2019-09-28T23:49:46",
"_links": <SNIPPED>
}

I also see the same data when I GET tickets resource.
curl -X GET "https://tasny.site/wp-json/ee/v4.8.36/tickets"

Then, I associate this ticket to a datetime like this:

curl -X POST -H "Authorization: Bearer token_here" -d "DTT_ID=23&TKT_ID=29" "https://tasny.site/wp-json/ee/v4.8.36/datetime_tickets"

Finally, I look at it in the Admin UI and it shows blank in the price box.

Let me know if you can reproduce this behavior or if you see something I am doing wrong with the API call.

I also tried using int (399) rather than 399.00 – same result.

Thanks!


Tony

  • Support Staff

August 16, 2019 at 9:39 am

Hi there,

Although you’ve created a ticket and set the price to the ticket object you haven’t created a price object and linked it to the ticket.

You need to create a price object with the relevant details (/prices/), then post to /ticket_prices/ to link the ticket you just created with that new price object, to do that you post the TKT_ID and PRC_ID (which you just created above).


Daniel

August 16, 2019 at 12:14 pm

Thank you for the quick reply!

I see… I was missing a relation. But, how can that field in tickets accept a price if the price (and price_type) is supposed to be set in the price model and joined with ticket_price? It looks like that data was accepted, it appears to be part of the json data returned by the GET, but then it is not available to the UI (I understand the UI is probably using the models directly instead of querying the API).

Just pointing that out since there is an inconsistency in the data being returned as if it was correctly registered, when in fact it was not.

Anyway, I found this page with a nice diagram that helps to understand:
https://github.com/eventespresso/event-espresso-core/blob/master/docs/G–Model-System/model-querying.md

Let me know if you agree that the json data is confusing to see when it’s not “real.”


Tony

  • Support Staff

August 21, 2019 at 6:03 am

But, how can that field in tickets accept a price if the price (and price_type) is supposed to be set in the price model and joined with ticket_price? It looks like that data was accepted, it appears to be part of the json data returned by the GET, but then it is not available to the UI (I understand the UI is probably using the models directly instead of querying the API).

The TKT_Price value is set on the ticket row, so it’s a valid value on a valid field for the ticket itself.

The admin pulls the ticket and the price objects (because a ticket can have more than a single price relation with modifiers etc) which is why it is not shown in the admin UI without the ticket_price relation.

Just pointing that out since there is an inconsistency in the data being returned as if it was correctly registered, when in fact it was not.

Sort of, the TKT_price value has been set and that’s what displays on the JSON output but the price relationship wasn’t set.

Let me know if you agree that the json data is confusing to see when it’s not “real.”

Whilst I get your point, the data set and shown was correct, you set a TKT_price value and that value was returned correct, if you checked for a valid relationship and it used the TKT_price to show the value on that relation, I’d agree, but I don’t think we can show a missing relationship easily with the current setup.

I’ll create a ticket and provide this feedback to the team so we can discuss this further.

The support post ‘Create Ticket with API. TKT_price is set but not visible on EE Admin UI’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  Tony 3 months, 3 weeks ago ago

Topic Tags

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!