1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Looking for a Coupon Plugin

Discussion in 'WordPress' started by Toon-c, Apr 28, 2014.

  1. #1
    Hi guys !

    I really need your help here,
    I'm looking for a plugin for wordpress for coupons.

    What I found so far, only plugins displaying coupons using shortcodes (in the post / page editor)

    What I want is a plugin that does not use shortcodes, maybe it will be using custom fileds.

    The reason for that is wanting to display a coupon block (div) after or before the article using php code in the page template.

    SO basically, I copy/paste a php code for displaying the plugin content anywhere I like it to display in the page template, and it will get the info from custom fields for example (or any field added o the wordpress editor)

    Any ideas ?

    WIll be really thankful
     
    Toon-c, Apr 28, 2014 IP
  2. carlo75

    carlo75 Active Member

    Messages:
    129
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    80
    #2
    Hi Toon-c,
    If I understand correctly, you want a plugin that use php code instead shortcode, in template php file of wordpress.

    So, try this: if you have find a coupon plugin that you like, you can simply use him shortcode with php, following this way:

    <?php
    echo do_shortcode("[Put_the_Shortcode]");
    ?>

    where "Put the Shortcode" can be something like [coupon couponid=1]

    Simply and easy. Nothing else.
    For reference:

    http://codex.wordpress.org/Function_Reference/do_shortcode

    Hope this can help.
    Regards.
     
    carlo75, Apr 30, 2014 IP
  3. Toon-c

    Toon-c Well-Known Member

    Messages:
    1,775
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    180
    #3
    That won't do it ...

    If I use that method, the same coupon will be shown in every page / post using the template file ..

    I want different coupons for different posts,

    That's why some kind of custom field to be added to each post is required ...

    Is that difficult to do / develop ? cause I've tried many coupon plugins and they all are similar, like no one thought to stand out for example ..
     
    Toon-c, Apr 30, 2014 IP
  4. carlo75

    carlo75 Active Member

    Messages:
    129
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    80
    #4
    Ok I better understand,
    if you want to use inside the loop, so you have to check the ID post.

    So in this case, you have to use custom fields.

    I suggest you ACF http://www.advancedcustomfields.com/

    Install it, make a new text custom fields and name Coupon ID.
    When you add a post, in the new field Coupon ID, insert the id of coupon you have created with the plugin, then in template file (single.php) edit the code using the php code for displaying the custom fields Coupon ID.

    For better understand see here:
    http://www.advancedcustomfields.com/resources/field-types/text/

    Hope this help.
    Regards.
     
    carlo75, Apr 30, 2014 IP
    Toon-c likes this.
  5. Toon-c

    Toon-c Well-Known Member

    Messages:
    1,775
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    180
    #5

    Sounds interesting ! I'll try it out , thanks very much !
     
    Toon-c, Apr 30, 2014 IP
  6. Toon-c

    Toon-c Well-Known Member

    Messages:
    1,775
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    180
    #6
    Hi,

    sorry for the double post,

    I did the above, but the post is displaying the shortcode as it is in the page, not the actual output ..

    So I see in the page
    [jcorgcrcoupon slug='C1' id='1']

    it's like a wysiwyg editor ...

    Maybe the coupon plugin doesn't allow shortcodes to work outside of post / page ?
    I'm using this one http://wordpress.org/plugins/jaspreetchahals-coupons-lite/
    (just testing)
     
    Toon-c, Apr 30, 2014 IP
  7. carlo75

    carlo75 Active Member

    Messages:
    129
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    80
    #7
    Hi no problem,
    plugin seems supporting shortcodes, but maybe it's a problem of syntax, in the video of author plugin, I see he use something like that:

    [jcorgcrcoupon id="17" slug="Jaspreet Chahal" /]

    Try testing with these...
     
    carlo75, Apr 30, 2014 IP
    Toon-c likes this.
  8. Toon-c

    Toon-c Well-Known Member

    Messages:
    1,775
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    180
    #8
    I tried different syntaxes but that doesn't change anything ...

    I tried putting this in the custom field
    <?php the_title(); ?>


    And if the custom fields settings that I'm using are rendering php code or shortcodes then the post title will show up,

    instead a plain <?php the_title(); ?> showed up ..

    SO I guess I need to check the custom fields plugin itself ? Am I at all logic here because I'm familiar with wordpress and a bit of code but far from being a developper !
     
    Toon-c, Apr 30, 2014 IP
  9. carlo75

    carlo75 Active Member

    Messages:
    129
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    80
    #9
    This:

    <?php the_field('name_of_new_added_custom_field_from_ACF'); ?>

    has to be putted in template php file of wordpress theme. At the moment, I'm away from a server test and can't make some screenshot but I try to explain the way.

    The sequence is:

    1. Install and activate ACF and your Coupon plugin
    2. Go to Coupon plugin -> Make a test coupon (save the coupon)
    3. grab the shortcode (similar [jcorgcrcoupon id="17" slug="Jaspreet Chahal" /]) (copy)
    4. Go to ACF -> Add new Field Group and name it CouponRelated (save)
    5. Now add new custom field: name it coupon and choose Text type (save)
    6. Make a new test post
    7. Bottom to this new post, you'll see a NEW field where adding the shortcode: here copy the shortcode (paste point 3)
    8. Publish the test post
    9. Now edit single.php of wordpress template you using
    10. Where you needs paste this <?php the_field('coupon'); ?>
    11. Save single.php
    12. Back to test post and check if you see the coupon
    Hope this help.
     
    Last edited: Apr 30, 2014
    carlo75, Apr 30, 2014 IP
    Toon-c likes this.
  10. Toon-c

    Toon-c Well-Known Member

    Messages:
    1,775
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    180
    #10
    Thanks, but That is what you described from the beginning and that's what I did exactly ..
     
    Toon-c, Apr 30, 2014 IP
  11. carlo75

    carlo75 Active Member

    Messages:
    129
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    80
    #11
    Mmm something wrong, when I've a server test, I'll try the code... now is a challenge :cool:
     
    carlo75, Apr 30, 2014 IP
    Toon-c likes this.
  12. Toon-c

    Toon-c Well-Known Member

    Messages:
    1,775
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    180
    #12
    :)
    I'll wait then !
     
    Toon-c, Apr 30, 2014 IP
  13. carlo75

    carlo75 Active Member

    Messages:
    129
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    80
    #13
    Here again,
    I remember now text field return string sorry.. try with this inside template file:

    <?php
    $value = get_field('coupon');
    $value = apply_filters('the_content', $value);
    echo $value
    ?>

    Let me know if now works.
     
    carlo75, Apr 30, 2014 IP
    Toon-c likes this.
  14. Toon-c

    Toon-c Well-Known Member

    Messages:
    1,775
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    180
    #14
    Well,

    it worked but with this code

    <?php echo( do_shortcode( get_post_meta( $post->ID , 'custom-field-name', true ) ) ); ?>

    Thanks man for the assistance ! really appreciate it !
     
    Toon-c, May 1, 2014 IP
    carlo75 likes this.