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.”

You must be logged in to reply to this support post. Sign In or Register for an Account

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: publish

Updated by  Daniel 4 days, 8 hours ago ago

Topic Tags

Notifications

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