[SOLVED] Issue with promotions, cbquery field and conditional

6 years 11 months ago - 6 years 11 months ago #294203 by webweaver.be
We upgraded joomla, CB, CBSubs and all plugins to the latest version this weekend.
Unfortunately we discovered an issue with one promotion that uses a cbquery field and a text field.

The promotion is now always active even though the condition is not met.

Query field: cb_currentyear: calculates the current year ("SELECT YEAR( current_date ) FROM `#__comprofiler` WHERE `id` = '[user_id]'")
Text field: cb_freemembshipin: administrator can enter a year in which the promotion is valid. Usually empty.

The promotion:
if value of cb_currentyear = value of cb_freemembshipin: apply a 100% discount

Current situation: even if the cb_freemembshipin field is empty, the promotion is applied.
We currently had to disable the promotion to prevent free discounts.


Please Log in to join the conversation.

6 years 11 months ago - 6 years 11 months ago #294212 by krileon
Your query isn't valid and is either erroring or just returning back empty value. You also don't need SQL to compare a field against current year. Use a condition from a substitution supported value against a field [cb:date format="Y" /] as the substitution. Example as follows.

Date A, Field A or Value A: Following CB field
CB Field A: cb_freemembshipin
Date B, Field B or Value B: Constant Value or String (CB substitutions can be used)
Value B: [cb:date format="Y" /]
Condition 1 (> for Dates): A = B (Value A is equal to Value B )

If you still want to use the query then the below should work, but I don't recommend doing an SQL query when it's not necessary.

SELECT YEAR( NOW() ) FROM `#__comprofiler` WHERE `id` = '[user_id]'


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: webweaver.be

Please Log in to join the conversation.

6 years 11 months ago #294263 by webweaver.be
Replied by webweaver.be on topic Issue with promotions, cbquery field and conditional
Hi Krileon,

The query itself is working as you can see in the second screenshot : www.joomlapolis.com/media/kunena/attachments/529283/chrome_2017-05-21_20-44-42.png and the same promotion worked properly in the previous version (4.1.0,build.2016.12.31)

However, I changed it from a cbquery field to cb:date and that seems to work.

Kind regards
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.188 seconds

Facebook Twitter LinkedIn