What are the PHP code limitations for price?

  • Posts: 2667
  • Karma: 76
  • Thank you received: 329

lovre replied the topic: What are the PHP code limitations for price?

Hi,

you should put regular php there, that calculates and sets the $price variable.

For example set a price depending on a user group as you mentioned:
$user = JFactory::getUser();
$groups = $user->get('groups');
foreach($groups as $group)
{ 
if ($group=='8') {$price='199';}
elseif ($group=='9') {$price='0';}
else {$price='10000';}
}
but be careful, users can be in more than one group.

You could tell us in a little bit few more words what exactly are you trying to accomplish so we can help you with more precise instructions/code.

Please let us know if this answers your question.

Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
===========================================
Need to renew Pro Support?
Buy Here!
===========================================
Satisfied?
Consider a membership!
===========================================
Like us on Facebook
===========================================
#188653
  • Posts: 108
  • Karma: -1
  • Thank you received: 0

Den replied the topic: What are the PHP code limitations for price?

Thanks for the quick response!!!)
I need to set fixed prices for different groups of customers on product or different properties by using BreezingForms.

Sorry for my bad English)))
#188712
  • Posts: 108
  • Karma: -1
  • Thank you received: 0

Den replied the topic: What are the PHP code limitations for price?

File Attachment:

File Name: Largeforma...ting.zip
File Size:33 KB



This is best done through BreezingForms or BreezingCommerce???
#188793
Attachments:
  • Posts: 2667
  • Karma: 76
  • Thank you received: 329

lovre replied the topic: What are the PHP code limitations for price?

Hello,

Yes, you can do this calculation either:

1. Through the BF element's actionscripts (JavaScript) and then just specify the price in the BC price plugin as the vaule of the TOTAL PRICE PRINT.

2. Completly through the BC price plugin. Your form doesn't need a TOTAL PRICE PRINT field as the $price variable will be calculated here. You would here do the same math as in #1 but in php. You would access an element value like this here:
$myvalue=$fields->SomeFieldName->value;

Bottom line you could do the calculation either way but I would suggest the #1 as it will dynamically show the price that would apply (in the read-only TOTAL PRICE PRINT element). #2 would just show do the calculated price on the checkout.

Let us know if you'll need help with the calculation.

Regards,

Lovre

Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
===========================================
Need to renew Pro Support?
Buy Here!
===========================================
Satisfied?
Consider a membership!
===========================================
Like us on Facebook
===========================================
#188875
  • Posts: 108
  • Karma: -1
  • Thank you received: 0

Den replied the topic: What are the PHP code limitations for price?

Thank for all you have described! I also thought that 1 option is better.

"Let us know if you'll need help with the calculation."

Show the sample actionscripts please to BF for different users group.
Thank you!!!
#188885
  • Posts: 2667
  • Karma: 76
  • Thank you received: 329

lovre replied the topic: What are the PHP code limitations for price?

Hello,

You can achieve this by doing the following:

1. Create a new textfield BF element, call it groupAddition and turn it off.
2. Go to Form> Form Pieces> Before Form> Custom:
$this->execPieceByName('ff_InitLib');
$user = JFactory::getUser();
$groups = $user->get('groups');
foreach($groups as $group)
{ 
if ($group=='1') {ff_setValue('groupAddition', '0'); }
elseif ($group=='2') {ff_setValue('groupAddition', '10'); }
elseif ($group=='3'){ff_setValue('groupAddition', '20');}
}

3. Your radiogroup element should be defined like this:
0;dpi1;80
0;dpi2;130
0;dpi3;180

4. radiogroup should have a "change" actionscript setting the A element like this:
function ff_radiogroupElementName_action(element, action)
{
ff_getElementByName('AElementName').value =Number(jQuery('[name="ff_nm_radiogroupElementName[]"]:checked').val()) + Number(ff_getElementByName('groupAddition').value);
}

Just be sure to change the radiogroupElementName and AElementName values in the code to your BF element names. You can keep the groupAddition value if you have done the step #1 exactly as described above.

Please try this out and let us know if it's working out for you.

Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
===========================================
Need to renew Pro Support?
Buy Here!
===========================================
Satisfied?
Consider a membership!
===========================================
Like us on Facebook
===========================================
#188906
Time to create page: 0.081 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here