CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Setting up fees for events using the Event API
Pages: [1]

Author Topic: Setting up fees for events using the Event API  (Read 779 times)

ade

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4.3
  • CMS version: wordpress
  • MySQL version: 5.5
  • PHP version: 5.3
Setting up fees for events using the Event API
April 15, 2013, 12:36:47 pm
Hi,

I'm creating an event using just the PHP API but I'm struggling to find any documentation or examples of creating fees for an event.  If anyone could shed any light on this or point me to a decent code example I would be most grateful!

Thanks,
Ade

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Setting up fees for events using the Event API
April 15, 2013, 12:50:24 pm
Hi,

There is an api to create price set, is this what you are looking for?

I would suggest you to create an event using the ui, and explore it using the api explorer, what it returns for the various entities is likely similar to what you will need to provide to create.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

ade

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4.3
  • CMS version: wordpress
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Setting up fees for events using the Event API
April 15, 2013, 02:24:27 pm
Thanks, I think I can work it out from the API explorer.  I'm quite new to Civi so still finding my way.

If I get a code sample together of creating an event, price set etc. and linking them all together I'll post it back online somewhere in case its of help to others.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Setting up fees for events using the Event API
April 15, 2013, 04:41:08 pm
Not to discourage you, but this is one of the most difficult things to do via the api. You have to use
event api
price_set api (and be sure to set entity_table and entity_id params to link it to your event)
price_field api
price_field_value api

Additionally, you'd need to use the loc_block api to give your an event a location.

BUT there is a much easier way, which I highly encourage if it suits your use case - you can use the api to create an event from a template. So the much simplified steps would be:
-Set up an event template the normal way with the civi ui
-Create your new event with all your params like title, start_date, end_date, etc and additionally pass the param template_id
This will clone the template, including price, location, online-registration, tell-a-friend and other settings, some of which aren't even available to the api.
Try asking your question on the new CiviCRM help site.

sonicthoughts

  • Ask me questions
  • ****
  • Posts: 498
  • Karma: 10
Re: Setting up fees for events using the Event API
December 11, 2014, 08:17:25 am
I realize this is an old topic, but trying to do a simple price set display using drupal views is quite a challenge.  Discussion and approaches on drupal civicrm_entity thread: https://www.drupal.org/node/2384405 .

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Setting up fees for events using the Event API

This forum was archived on 2017-11-26.