• Resolved snowcondor

    (@snowcondor)


    I’m attempting to add a time-sensitive discount code component into my GeoDirectory business post type. I couldn’t find any other posts related to this.

    My current approach is to add 4 fields, “discount_description”, “discount_code”, “discount_expiry_date”, “discount_active”, and then somehow filter the post_meta before it is output so as to not publish any of these fields in the final post if the discount_expiry_date has been passed or the discount_active is false.

    My guess is that I need to make a custom shortcode for the output or to somehow hook into the gd_post_meta shortcode, but I’m not entirely sure how to go about this as I can’t find enough information in the GeoDirectory documentation or by searching the code to help me determine how to tap into it or what object to modify if anything.

    I have the Code Snippets plugin installed. Any help would be much appreciated.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Stiofan

    (@stiofansisland)

    Hello,

    I have made the Dynamic Content block work with custom date fields, it will be in the release on Thursay but if you want to test now then please repalce this file in your plugin https://github.com/AyeCode/geodirectory/blob/master/includes/widgets/class-geodir-widget-dynamic-content.php

    Once done you can use it to select the discount expiry field, then do a less than check and in the search you canput +0 or the +/- represents the days before or after the current date, to you might need to put +1 to include the current day.

    In the text field you can use the field key to output the discount code dynamically such as %%discount_code%%

    Thanks,

    Stiofan

    Thread Starter snowcondor

    (@snowcondor)

    Hi Stiofan,

    Thank you so much for such a quick response and solution. I initially was confused at what you meant by the Dynamic Content block but I found it in the shortcode maker and worked it out from there. So my shortcode now essentially looks like:

    [gd_dynamic_content key=”discount_expiry_date” condition=”is_less_than” search=”+0″]%%discount_code%%[/gd_dynamic_content]

    I assume I can use this for the description field and date field as well. So thank you so much.

    Would it also be possible to use more than one condition? For instance, if I want to use a “discount_active” Boolean condition to turn it off prematurely but keep the date. I attempted to use a shortcode within a shortcode but that didn’t work.

    Kindest regards

    Mitch

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Logic in Custom Post Types – Time sensitive output’ is closed to new replies.