Coupon Batches

Discussion in 'Templates customization' started by jackgordon, Apr 28, 2009.

  1. jackgordon

    jackgordon Member

    Joined:
    Mar 23, 2009
    Messages:
    269
    Is there any way I could tweak the code on the page that lists coupon batches to display the actual coupon code and/or the comment field inside the "edit" area?

    The page is not friendly for managing more than a couple of coupons. I would be willing to sacrifice the "Batch ID" field and replace it with one of the above instead (including link)

    How might I do this?
  2. powerkeys

    powerkeys Member

    Joined:
    Aug 29, 2006
    Messages:
    192
    Since I also generate "batches" of 1 coupon each, I would also like to show the coupon code on the main "coupon batches" screen.

    I understand that others may generate 10, 20, or even 100 codes per batch, if we could have the OPTION to list the 1st coupon code per batch on this screen, it would really be nice.
  3. codeispoetry

    codeispoetry aMember Pro Customer

    Joined:
    Jan 12, 2009
    Messages:
    336
    Not advisable to tweak on your own, you may mess up the Admin screen.

    Highly recommended to log a helpdesk ticket and request for improvements :)

    Lee
  4. codeispoetry

    codeispoetry aMember Pro Customer

    Joined:
    Jan 12, 2009
    Messages:
    336
    Not advisable to tweak on your own, you may mess up the Admin screen.

    Highly recommended to log a helpdesk ticket and request for improvements :)

    Lee
  5. jackgordon

    jackgordon Member

    Joined:
    Mar 23, 2009
    Messages:
    269
    I took Code's advice and submitted a ticket. I got the tweaks necessary to change the linked batch # in the "Coupon Batches" page to be the comment field inside the edit screen.

    See attached screenshots for a better illustration of the change.

    Here is the code:

    Edit /amember/plugins/db/mysql/mysql.inc.php and change this:

    function get_coupon_batches(){
    $q = $this->query("SELECT DISTINCT batch_id,
    COUNT(*) AS coun,
    MIN(begin_date) AS begin_date1,
    MAX(begin_date) AS begin_date2,
    MIN(expire_date) AS expire_date1,
    MAX(expire_date) AS expire_date2,
    SUM(use_count) AS use_count,
    SUM(IFNULL(used_count,0)) AS used_count,
    SUM(locked) AS locked_count
    FROM {$this->config['prefix']}coupon
    GROUP BY batch_id
    ORDER BY batch_id
    ");
    $rows = array();
    while ($r = mysql_fetch_assoc($q)){
    $rows[] = $r;
    }
    return $rows;
    }


    to


    function get_coupon_batches(){
    $q = $this->query("SELECT DISTINCT batch_id,comment,
    COUNT(*) AS coun,
    MIN(begin_date) AS begin_date1,
    MAX(begin_date) AS begin_date2,
    MIN(expire_date) AS expire_date1,
    MAX(expire_date) AS expire_date2,
    SUM(use_count) AS use_count,
    SUM(IFNULL(used_count,0)) AS used_count,
    SUM(locked) AS locked_count
    FROM {$this->config['prefix']}coupon
    GROUP BY batch_id
    ORDER BY batch_id
    ");
    $rows = array();
    while ($r = mysql_fetch_assoc($q)){
    $rows[] = $r;
    }
    return $rows;
    }


    Then change /amember/templates/admin/coupon_batches.html template:
    <td><a href="coupons.php?action=view_batch&batch_id={$b.batch_id}">{$b.batch_id}</a></td>
    to
    <td><a href="coupons.php?action=view_batch&batch_id={$b.batch_id}">{$b.comment}</a></td>
  6. powerkeys

    powerkeys Member

    Joined:
    Aug 29, 2006
    Messages:
    192
    The only change I see in the function code here is the addition of the comment field in the 2nd line.

    Just to verify -- to really use this, we'd also need to manually edit each coupon code to match the comment field, correct?
  7. jackgordon

    jackgordon Member

    Joined:
    Mar 23, 2009
    Messages:
    269
    Whatever content you put in the comment field will show up as the batch id. I don't believe there is any requirement to edit the coupon codes.

    As long as the comment field describes what the coupon is for, you should be all set.
  8. powerkeys

    powerkeys Member

    Joined:
    Aug 29, 2006
    Messages:
    192
    Hi Jack,

    Yes, I understand that, however, I was referring to our earlier discussion about having the actual coupon code show up on the main coupon page. Since this patch places the COMMENT on that page, and not the actual COUPON CODE, then in order to see the coupon code on that screen, we'd have to manually edit the codes to match the comments.

    I understand that this patch meets your original request (codes and/or comment), and I was just wanting to verify that the extra step will be needed to meet my needs.
  9. jackgordon

    jackgordon Member

    Joined:
    Mar 23, 2009
    Messages:
    269
    ah, I see what you are getting at.

    I am not really qualified to answer your question. However, from what I can tell, it should be just as easy to use the actual coupon code as it is to use the comment field, with the notable exception being how do you handle multiple coupon codes in one batch.

    My suggestion? Go the ticket route. Or, just use the coupon code in the comment field.

    I realize I have been no help whatsoever. :) Hopefully, someone else will chime in with actual guidance.
  10. powerkeys

    powerkeys Member

    Joined:
    Aug 29, 2006
    Messages:
    192
    Actually, you've answered my question and verified that I see it correctly.

    Doing the manual editing is not a problem for me. I just wanted to verify that it is, in fact, necessary in order to get what I'm after in this.
  11. hunteridge

    hunteridge New Member

    Joined:
    Jul 13, 2007
    Messages:
    8
    thanks guys.

    I added one piece to get the codes to show next to the comments so you don't have to open up the Edit to see the code to use...

    Edit /amember/plugins/db/mysql/mysql.inc.php and change this:

    $q = $this->query("SELECT DISTINCT batch_id,

    to

    $q = $this->query("SELECT DISTINCT batch_id,comment,code,



    Then change /amember/templates/admin/coupon_batches.html template:

    <td><a href="coupons.php?action=view_batch&batch_id={$b.batch_id}">{$b.batch_id}</a></td>

    to

    <td><a href="coupons.php?action=view_batch&batch_id={$b.batch_id}">{$b.comment} / {$b.code}</a></td>

    AND also....

    <th>Batch ID</th>

    to

    <th>Batch ID / Coupon Code</th>

Share This Page