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) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Group discounts?
Pages: 1 [2]

Author Topic: Group discounts?  (Read 3182 times)

benjeewest

  • Guest
Re: Group discounts?
August 18, 2009, 08:53:19 am
Thanks once again- a lifesaver- hooks aren't nearly as scary as I thought!

Hate to keep bothering, but just two further questions I was hoping you'd be kind enough to help me out with (know how annoying users like me can be, so apologies for taking up your time- I imagine you're a very busy guy!):

1) I've created a discount code to reduce prices by 10% which (as you'd expect) reduces a price of £30 to £27, £20 to £18 as it should. However, for other amounts which produce a decimal figure, it seems to be rounding the fee to the nearest GBP, rather than displaying pence, e.g. so £25 is reduced to £22 instead of £22.50, £26 to £23 and £18 is reduced to £16 rather than £16.20. Is this a bug which I should report, or is this a feature of the script? Not a biggie either way.

2) Is it possible to create more than one coupon per event? If so, how do I need to adapt the MySQL query for a second time round?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Group discounts?
August 18, 2009, 09:10:05 am

1. personally we like dealing with round number and hence the code reflects that. You can change that in the hook, the relevant lines to fix are (removing the ceil function call should address your issue)

Code: [Select]
        $amount[$amountId]['value'] = $amount[$amountId]['value'] -
            ceil($amount[$amountId]['value'] * $discountPercent / 100);

you might want to keep it to just 2 decimal digits and make sure u format the number properly (check number_format in the php manual)

2. the code is already setup to allow multiple coupons per event. Just add it to the option value table.

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Group discounts?

This forum was archived on 2017-11-26.