Esempio n. 1
0
 /**
  * Mark coupons as used
  *
  * @param $order_id
  * @param $post
  */
 public function order_processed($order_id, $post)
 {
     if (class_exists('FUE_Reports')) {
         // look for used coupons
         $coupons = get_post_meta($order_id, 'coupons');
         if (!empty($coupons)) {
             // look for this coupon in the coupons log and update it
             foreach ($coupons as $coupon) {
                 if (strpos($coupon, ',') !== false) {
                     $codes = explode(',', $coupon);
                 } else {
                     $codes = array($coupon);
                 }
                 foreach ($codes as $code) {
                     $code = trim($code);
                     if (empty($code)) {
                         continue;
                     }
                     FUE_Coupons::mark_used_coupon($code);
                 }
             }
         }
     }
 }
    public static function coupons_html()
    {
        global $wpdb, $woocommerce;
        $coupons = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}followup_coupons ORDER BY `coupon_name` ASC");
        $html = '
    <div class="wrap woocommerce">
        <div class="icon32"><img src="' . FUE_TEMPLATES_URL . '/images/send_mail.png' . '" /></div>
        <h2>
            ' . __('Follow-Up Emails &raquo; Email Coupons', 'follow_up_emails') . '
            <a href="admin.php?page=followup-emails-coupons&action=new-coupon" class="add-new-h2">' . __('Add Coupon', 'wc_followup_emalis') . '</a>
        </h2>

    <form action="admin-post.php" method="post">
        <table class="wp-list-table widefat fixed posts">
            <thead>
                <tr>
                    <th scope="col" id="name" class="manage-column column-name" style="">' . __('Name', 'follow_up_emails') . '</th>
                    <th scope="col" id="type" class="manage-column column-type" style="">' . __('Type', 'follow_up_emails') . '</th>
                    <th scope="col" id="amount" class="manage-column column-amount" style="">' . __('Amount', 'follow_up_emails') . '</th>
                    <th scope="col" id="usage_count" class="manage-column column-usage_count" style="">' . __('Sent', 'follow_up_emails') . '</th>
                </tr>
            </thead>
            <tbody id="the_list">';
        if (empty($coupons)) {
            $html .= '
                <tr scope="row">
                    <th colspan="4">' . __('No coupons available', 'follow_up_emails') . '</th>
                </tr>';
        } else {
            foreach ($coupons as $coupon) {
                $html .= '
                <tr scope="row">
                    <td class="post-title column-title">
                        <strong><a class="row-title" href="admin.php?page=followup-emails-coupons&action=edit-coupon&id=' . $coupon->id . '">' . stripslashes($coupon->coupon_name) . '</a></strong>
                        <div class="row-actions">
                            <span class="edit"><a href="admin.php?page=followup-emails-coupons&action=edit-coupon&id=' . $coupon->id . '">' . __('Edit', 'follow_up_emails') . '</a></span>
                            |
                            <span class="trash"><a onclick="return confirm(\'Really delete this entry?\');" href="admin.php?page=followup-emails-coupons&action=delete-coupon&id=' . $coupon->id . '">' . __('Delete', 'follow_up_emails') . '</a></span>
                        </div>
                    </td>
                    <td>' . FUE_Coupons::get_discount_type($coupon->coupon_type) . '</td>
                    <td>' . floatval($coupon->amount) . '</td>
                    <td>' . $coupon->usage_count . '</td>
                </tr>
                ';
            }
        }
        $html .= '
            </tbody>
        </table>
    </form>
    </div>';
        return $html;
    }
 public function settings_main()
 {
     echo FUE_Coupons::coupons_html();
 }
Esempio n. 4
0
</a></span>
                        |
                        <span class="trash"><a onclick="return confirm('<?php 
        _e('Really delete this entry?', 'follow_up_emails');
        ?>
');" href="admin-post.php?action=fue_delete_coupon&id=<?php 
        echo $coupon->id;
        ?>
"><?php 
        _e('Delete', 'follow_up_emails');
        ?>
</a></span>
                    </div>
                </td>
                <td><?php 
        echo FUE_Coupons::get_discount_type($coupon->coupon_type);
        ?>
</td>
                <td><?php 
        echo floatval($coupon->amount);
        ?>
</td>
                <td><?php 
        echo $coupon->usage_count;
        ?>
</td>
            </tr>
            <?php 
    }
}
?>
Esempio n. 5
0
<?php

$categories = get_terms('product_cat', array('order_by' => 'name', 'order' => 'ASC'));
$coupon_id = isset($_GET['id']) ? absint($_GET['id']) : 0;
$data = FUE_Coupons::get_coupon_data($coupon_id);
if ($coupon_id > 0) {
    $action = 'update';
} else {
    $action = 'create';
}
?>
<div class="wrap woocommerce">
<div class="icon32"><img src="<?php 
echo FUE_TEMPLATES_URL . '/images/send_mail.png';
?>
" /></div>
    <h2>
        <?php 
if ($action == 'create') {
    _e('Create a New Coupon', 'follow_up_emails');
} else {
    _e('Update Coupon', 'follow_up_emails');
}
?>
    </h2>
    <form action="admin-post.php" method="post">

        <div id="poststuff">
            <div id="post-body">
                <div class="postbox-container" id="postbox-container-2" style="float:none; width: 75%;">
                    <div id="normal-sortables">