コード例 #1
0
 public static function dailySubscriptionEmailReminderCheck()
 {
     Cart66Setting::setValue('daily_subscription_reminders_last_checked', Cart66Common::localTs());
     // Function that fires daily to send out subscription reminder emails.  This will be triggered once a day at 3 AM.
     // If this function fires emails will be sent.
     $dayStart = date('Y-m-d 00:00:00', Cart66Common::localTs());
     $dayEnd = date('Y-m-d 00:00:00', strtotime('+ 1 day', Cart66Common::localTs()));
     $reminder = new Cart66MembershipReminders();
     $reminders = $reminder->getModels();
     foreach ($reminders as $r) {
         if ($r->enable == 1) {
             $interval = explode(',', $r->interval);
             foreach ($interval as $i) {
                 $new_interval = trim($i) . ' ' . $r->interval_unit;
                 $product = new Cart66Product($r->subscription_plan_id);
                 $start = date('Y-m-d H:i:s', strtotime('+ ' . $new_interval, strtotime($dayStart)));
                 $end = date('Y-m-d H:i:s', strtotime('+ ' . $new_interval, strtotime($dayEnd)));
                 $sub = new Cart66AccountSubscription();
                 $subs = $sub->getModels("where active_until >= '{$start}' AND active_until < '{$end}' AND lifetime != '1' AND product_id = '{$product->id}'");
                 $log = array();
                 foreach ($subs as $s) {
                     if ($r->validateReminderEmails($s->id)) {
                         $r->sendReminderEmails($s->id);
                         $log[] = $s->id . ' :: ' . $s->billing_first_name . ' ' . $s->billing_last_name;
                     }
                 }
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Start: {$start} :: End: {$end}");
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] subscription ids that meet the criteria: " . print_r($log, true));
             }
         }
     }
 }
コード例 #2
0
 public function saveEmailLog($email_data, $email_type, $copy, $status)
 {
     if (Cart66Setting::getValue('enable_email_log') == 1) {
         global $wpdb;
         $date = date("Y-m-d H:i:s", Cart66Common::localTs());
         if (is_array($email_data['msg'])) {
             $email_data['msg'] = $email_data['msg']['text/plain'] . '\\n\\n' . $email_data['msg']['text/html'];
         }
         $data = array('send_date' => $date, 'from_email' => $email_data['from_email'], 'from_name' => $email_data['from_name'], 'to_email' => $email_data['to_email'], 'to_name' => $email_data['to_name'], 'headers' => $email_data['head']['headers'], 'subject' => $email_data['subject'], 'body' => $email_data['msg'], 'attachments' => $email_data['attachments'], 'order_id' => $email_data['order_id'], 'email_type' => $email_type, 'copy' => $copy, 'status' => $status);
         $logTable = Cart66Common::getTableName('email_log');
         $wpdb->insert($logTable, $data);
         $emailLogId = $wpdb->insert_id;
         Cart66Common::log("Saved email log ({$emailLogId}): " . $data['status'] . "\nSQL: " . $wpdb->last_query . ' ' . Cart66Common::localTs());
     }
 }
コード例 #3
0
 public function validateExpDate()
 {
     $isValid = true;
     $thisYear = date('Y');
     if ($this->_cardData['month'] < 1 || empty($this->_cardData['month'])) {
         $isValid = false;
         $this->_errors[] = 'Invalid credit card month';
     } elseif ($this->_cardData['year'] < $thisYear) {
         $isValid = false;
         $this->_errors[] = 'Invalid credit card year';
     } else {
         $today = strtotime('now', Cart66Common::localTs());
         $expDate = strtotime($this->_cardData['month'] . '/28/' . $this->_cardData['year']);
         if ($today >= $expDate) {
             $isValid = false;
             $this->_errors[] = "Credit card has expired";
         }
     }
     return $isValid;
 }
 public static function updateDate($attrs)
 {
     $date = strstr($attrs['att'], ':');
     $date = substr($date, 1);
     $output = date($date, Cart66Common::localTs());
     return $output;
 }
コード例 #5
0
ファイル: debug.php プロジェクト: rbredow/allyzabbacart
              <input type="hidden" name="cart66-action" value="prune pending orders" id="cart66-action" />
              <input type="submit" value="<?php 
_e('Prune Pending Orders', 'cart66');
?>
" class="button-secondary" />
            </form>
          </td>
        </tr>
        <tr valign="top">
          <th scope="row"><?php 
_e('Next Scheduled Cron Check', 'cart66');
?>
</th>
          <td>
            <?php 
echo Cart66Common::getTimeLeft(date('Y-m-d H:i:s', Cart66Common::localTs(wp_next_scheduled('daily_subscription_reminder_emails')))) . ' (' . date('Y-m-d H:i:s', Cart66Common::localTs(wp_next_scheduled('daily_subscription_reminder_emails'))) . ')';
?>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</div>
<script type="text/javascript">
  (function($){
    $(document).ready(function(){
      $('#cart66-inner-tabs div.pane').hide();
      $('#cart66-inner-tabs div#<?php 
echo $tab;
?>
').show();
コード例 #6
0
ファイル: Cart66Order.php プロジェクト: rbredow/allyzabbacart
 public function dailyPrunePendingPayPalOrders()
 {
     Cart66Setting::setValue('daily_prune_pending_orders_last_checked', Cart66Common::localTs());
     $o = new Cart66Order();
     $dayStart = date('Y-m-d 00:00:00', strtotime('48 hours ago', Cart66Common::localTs()));
     $dayEnd = date('Y-m-d 00:00:00', strtotime('24 hours ago', Cart66Common::localTs()));
     $orders = $o->getOrderRows("WHERE status in ('paypal_pending','checkout_pending') AND ordered_on >= '{$dayStart}' AND ordered_on < '{$dayEnd}'");
     foreach ($orders as $order) {
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] yes, i am to delete an order or more: " . $order->id);
         $o->load($order->id);
         $o->deleteMe(true, true);
     }
 }
コード例 #7
0
ファイル: reports.php プロジェクト: rbredow/allyzabbacart
if (CART66_PRO) {
    require_once CART66_PATH . "/pro/admin/reports.php";
} else {
    echo '<p class="description">' . __('Sales reports are only available in <a href="http://cart66.com">Cart66 Professional</a>.', 'cart66') . '</p>';
}
?>
  
  <br/>
  
  <h3><?php 
_e('Export Orders', 'cart66');
?>
</h3>
  
  <?php 
$firstDayLastMonth = date("m/1/Y", strtotime('-1 month', Cart66Common::localTs()));
$lastDayLastMonth = date("m/d/Y", strtotime('-1 day', strtotime('+1 month', strtotime($firstDayLastMonth))));
?>
  <form action="" method="post" style="margin-bottom: 25px;">
    <input type="hidden" name="cart66-action" value="export_csv" />
    <table class="">
      <tr>
        <th style="text-align: left; padding: 0px 5px;"><?php 
_e('Start Date', 'cart66');
?>
</th>
        <th style="text-align: left; padding: 0px 5px;"><?php 
_e('End Date', 'cart66');
?>
</th>
        <th>&nbsp;</th>
コード例 #8
0
                  <td bgcolor="#ccc" height="20">
                  </td>
                </tr>
              </table>
              <!-- End Footer -->

            </td>
          </tr>
        </table>
        <!-- End Main Table -->
      </div>
    </body>
    </html>
  <?php 
    } else {
        $reminderId = $data[3];
        $reminder = new Cart66MembershipReminders($reminderId);
        $msg = "Dear Test User,\n\n";
        $msg .= "Your subscription : Default Membership expires " . date(get_option('date_format'), strtotime('+ 30 days', Cart66Common::localTs())) . ".\n\n";
        $msg .= "=========================\n\n";
        $msg .= "Please log-in to your account and renew your subscription.\n\n";
        $msg .= "Your login details:\n";
        $msg .= "Your User ID: username\n";
        $msg .= "You can reset your password at the membership page\n\n";
        $msg .= "Thank you for your attention!";
        $msg .= "--\n\n";
        $msg .= "Best Regards,\n";
        $msg .= "{$reminder->from_name}\n";
        $msg .= "{$reminder->from_email}";
    }
}
コード例 #9
0
 /**
  * Store order in database after successful transaction is processed
  */
 public function saveOrder($total, $tax, $transId, $status, $accountId = 0)
 {
     $address = $this->getShipping();
     $b = $this->getBilling();
     $p = $this->getPayment();
     $orderInfo['ship_first_name'] = $address['firstName'];
     $orderInfo['ship_last_name'] = $address['lastName'];
     $orderInfo['ship_address'] = $address['address'];
     $orderInfo['ship_address2'] = $address['address2'];
     $orderInfo['ship_city'] = $address['city'];
     $orderInfo['ship_state'] = $address['state'];
     $orderInfo['ship_zip'] = $address['zip'];
     $orderInfo['ship_country'] = Cart66Common::getCountryName($address['country']);
     $orderInfo['bill_first_name'] = $b['firstName'];
     $orderInfo['bill_last_name'] = $b['lastName'];
     $orderInfo['bill_address'] = $b['address'];
     $orderInfo['bill_address2'] = $b['address2'];
     $orderInfo['bill_city'] = $b['city'];
     $orderInfo['bill_state'] = $b['state'];
     $orderInfo['bill_zip'] = $b['zip'];
     $orderInfo['bill_country'] = Cart66Common::getCountryName($b['country']);
     $orderInfo['phone'] = preg_replace("/[^0-9]/", "", $p['phone']);
     $orderInfo['email'] = $p['email'];
     $orderInfo['custom_field'] = isset($p['custom-field']) ? $p['custom-field'] : '';
     $orderInfo['coupon'] = Cart66Common::getPromoMessage();
     $orderInfo['tax'] = $tax;
     $orderInfo['shipping'] = Cart66Session::get('Cart66Cart')->getShippingCost();
     $orderInfo['subtotal'] = Cart66Session::get('Cart66Cart')->getSubTotal();
     $orderInfo['total'] = preg_replace("/[^0-9\\.]/", "", $total);
     $orderInfo['trans_id'] = $transId;
     $orderInfo['status'] = $status;
     $orderInfo['ordered_on'] = date('Y-m-d H:i:s', Cart66Common::localTs());
     $orderInfo['shipping_method'] = Cart66Session::get('Cart66Cart')->getShippingMethodName();
     $orderInfo['account_id'] = $accountId;
     $additional_fields = array();
     $custom_payment_fields = apply_filters('cart66_after_payment_form', '');
     if (is_array($custom_payment_fields)) {
         foreach ($custom_payment_fields as $key => $payment_field) {
             if (isset($p[$payment_field['slug']])) {
                 $additional_fields[$payment_field['section']][$payment_field['slug']] = array('label' => $payment_field['label'], 'value' => $p[$payment_field['slug']]);
             }
         }
     }
     $custom_billing_fields = apply_filters('cart66_after_billing_form', '');
     if (is_array($custom_billing_fields)) {
         foreach ($custom_billing_fields as $key => $billing_field) {
             if (isset($b[$billing_field['slug']])) {
                 $additional_fields[$billing_field['section']][$billing_field['slug']] = array('label' => $billing_field['label'], 'value' => $b[$billing_field['slug']]);
             }
         }
     }
     $custom_shipping_fields = apply_filters('cart66_after_shipping_form', '');
     if (is_array($custom_shipping_fields)) {
         foreach ($custom_shipping_fields as $key => $shipping_field) {
             if (isset($address[$shipping_field['slug']])) {
                 $additional_fields[$shipping_field['section']][$shipping_field['slug']] = array('label' => $shipping_field['label'], 'value' => $address[$shipping_field['slug']]);
             }
         }
     }
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] additional fields: " . print_r($additional_fields, true));
     if (!empty($additional_fields)) {
         $orderInfo['additional_fields'] = serialize($additional_fields);
     }
     $orderInfo = Cart66Common::deNullArrayValues($orderInfo);
     $orderId = Cart66Session::get('Cart66Cart')->storeOrder($orderInfo);
     return $orderId;
 }
コード例 #10
0
    public static function cart66_statistics_widget()
    {
        function totalFromRange($start, $end)
        {
            global $wpdb;
            $tableName = Cart66Common::getTableName('orders');
            $sql = "SELECT sum(total) as total from {$tableName} where ordered_on > '{$start}' AND ordered_on < '{$end}'";
            $result = $wpdb->get_row($sql, ARRAY_A);
            $output = $result ? (double) $result['total'] : "N/A";
            return $output;
        }
        // TODAY
        $yday = date('Y-m-d 00:00:00', strtotime('yesterday'));
        $dayStart = date('Y-m-d 00:00:00', strtotime('today'));
        $dayEnd = date('Y-m-d 00:00:00', strtotime('tomorrow'));
        $mdayStart = date('Y-m-01 00:00:00', strtotime('today'));
        $mdayEnd = date('Y-m-01 00:00:00', strtotime('next month'));
        $today_total = totalFromRange($dayStart, $dayEnd);
        $yesterday_total = totalFromRange($yday, $dayStart);
        $month_total = totalFromRange($mdayStart, $mdayEnd);
        $total_product_sales = Cart66DataTables::productsSearch();
        $total_sales_amount = Cart66DataTables::totalSalesForMonth($total_product_sales);
        $daily_avg = ($month_total - $today_total) / date('j', strtotime('yesterday'));
        //number_format($month_total/date("j"),2);
        $total_days = date('t', strtotime('now'));
        $est_month = $total_days * $daily_avg;
        ?>
    <div class="cart66Tabbed">
      <ul class="tabs">
        <li class="t1"><a class="t1 tab" href="javascript:void(0)"><?php 
        _e('Summary', 'cart66');
        ?>
</a></li>
        <li class="t2"><a class="t2 tab" href="javascript:void(0)"><?php 
        _e('Today/Yesterday', 'cart66');
        ?>
</a></li>
        <li class="t3"><a class="t3 tab" href="javascript:void(0)"><?php 
        echo date("F, Y", strtotime("now"));
        ?>
</a></li>
        <li class="t4"><a class="t4 tab" href="javascript:void(0)"><?php 
        _e('Daily Average', 'cart66');
        ?>
</a></li>
        <li class="t5"><a class="t5 tab" href="javascript:void(0)"><?php 
        _e('Estimate', 'cart66');
        ?>
</a></li>
      </ul>
      <div class="loading">
        <h2 class="center"><?php 
        _e('loading...', 'cart66');
        ?>
</h2>
      </div>
      <div class="t1 pane">
        <table id="statSummary" cellspacing="0" cellpadding="0">
        <tfoot>
        <tr>
          <td>
           <?php 
        _e('Last Updated', 'cart66');
        ?>
:
          </td>
          <td class="right">
            <?php 
        echo date(get_option('date_format'), Cart66Common::localTs());
        ?>
 <?php 
        echo date(get_option('time_format'), Cart66Common::localTs());
        ?>
          </td>
        </tr>
        </tfoot>
          <tbody>
          <tr class="t4 tab summaryDetails">
            <td>
             <?php 
        echo date('F');
        _e(' Daily Average', 'cart66');
        ?>
:
            </td>
            <td class="right">
             <a class="t4 tab" href="javascript:void(0)"><?php 
        echo Cart66Common::currency($daily_avg);
        ?>
</a>
            </td>
          </tr>
          <tr class="t2 tab summaryDetails">
            <td>
              <?php 
        _e('Today\'s Total', 'cart66');
        ?>
:
            </td>
            <td class="right">
              <a class="t2 tab" href="javascript:void(0)"><?php 
        echo Cart66Common::currency($today_total);
        ?>
</a>
            </td>
          </tr>
          <tr class="t2 tab summaryDetails">
            <td>
              <?php 
        _e('Yesterday\'s Total', 'cart66');
        ?>
:
            </td>
            <td class="right">
              <a class="t2 tab" href="javascript:void(0)"><?php 
        echo Cart66Common::currency($yesterday_total);
        ?>
</a>
            </td>
          </tr>
          <tr class="t3 tab summaryDetails">
            <td>
              <?php 
        echo date("F", strtotime("now"));
        ?>
 <?php 
        _e('Total', 'cart66');
        ?>
:
            </td>
            <td class="right">
             <a class="t3 tab" href="javascript:void(0)"><?php 
        echo Cart66Common::currency($month_total);
        ?>
</a>
            </td>
          </tr>
          <tr class="t5 tab summaryDetails">
            <td>
             <?php 
        _e('Estimated', 'cart66');
        ?>
 <?php 
        echo date("F", strtotime('now'));
        ?>
 <?php 
        _e('Total', 'cart66');
        ?>
:
            </td>
            <td class="right">
             <a class="t5 tab" href="javascript:void(0)"><?php 
        echo Cart66Common::currency($est_month);
        ?>
</a>
            </td>
          </tr>
          </tbody>
        </table>
      </div>
      <div class="t2 pane">
        <table id="dayStats" cellpadding="0" cellspacing="0">
          <tr class="summaryDetails dayStats">
            <td>
              <?php 
        _e('Today\'s Total', 'cart66');
        ?>
: <strong><?php 
        echo Cart66Common::currency($today_total);
        ?>
</strong>
            </td>
            <td class="right">
              <?php 
        _e('Yesterday\'s Total', 'cart66');
        ?>
: <strong><?php 
        echo Cart66Common::currency($yesterday_total);
        ?>
</strong>
            </td>
          </tr>
          <tr>
            <td class="wideOrders" colspan="2">
              <table width="100%" id="todaysOrders" cellpadding="0" cellspacing="0">
              <thead>
                <tr>
                  <th colspan="2" class="left"><?php 
        _e('Today\'s Order Details', 'cart66');
        ?>
</th>
                  <th class="right"><?php 
        _e('Order Total', 'cart66');
        ?>
</th>
                </tr>
                </thead>
              <?php 
        $Orders = new Cart66Order();
        $todaysOrders = $Orders->getOrderRows(" WHERE ordered_on > '{$dayStart}' AND ordered_on < '{$dayEnd}' AND id>0", "order by ordered_on DESC");
        if ($todaysOrders) {
            $i = 1;
            ?>
                <tbody>
                  <?php 
            foreach ($todaysOrders as $order) {
                ?>
                    <tr>
                      <td class="rowNumber">
                        <h2><?php 
                echo $i;
                ?>
</h2>
                      </td>
                      <td class="orderInformation">
                        <p><?php 
                echo $order->bill_first_name . " " . $order->bill_last_name;
                ?>
<br>
                          <span class='orderDate'><?php 
                echo Cart66Common::getElapsedTime($order->ordered_on);
                ?>
</span>
                        </p>
                      </td>
                      <td class='right'>
                        <?php 
                echo Cart66Common::currency($order->total);
                ?>
                      </td>
                      <?php 
                $i++;
                ?>
                    </tr>
                  <?php 
            }
            ?>
                </tbody>
                <?php 
        } else {
            ?>
                <tfoot>
                <tr>
                  <td colspan='3'>
                    <h2 class="noOrders"><?php 
            _e('No orders yet today', 'cart66');
            ?>
</h2>
                  </td>
                </tr>
                </tfoot>
              <?php 
        }
        ?>
              </table>
            </td>
          </tr>
        </table>    
      </div>
      <div class="t3 pane">
        <table id="productTable" cellpadding="0" cellspacing="0">
          <tr>
            <thead>
              <tr>
                <th class="left"><?php 
        _e('Product Name', 'cart66');
        ?>
</th>
                <th class="center"><?php 
        _e('Sales', 'cart66');
        ?>
</th>
                <th class="right"><?php 
        _e('Income', 'cart66');
        ?>
</th>
              </tr>
            </thead>
            <tfoot>
              <tr>
                <th class="left"><strong><?php 
        echo date("F, Y", strtotime('now'));
        ?>
</strong></th>
                <?php 
        if (isset($total_sales_amount['total_sales'])) {
            $totalSales = $total_sales_amount['total_sales']['total_quantity'];
            $totalAmount = $total_sales_amount['total_sales']['total_amount'];
        } else {
            $totalSales = '0';
            $totalAmount = '0';
        }
        ?>
                <th class="center"><strong><?php 
        echo $totalSales;
        ?>
</strong></th>
                <th class="right"><strong><?php 
        echo Cart66Common::currency($totalAmount);
        ?>
</strong></th>
              </tr>
            </tfoot>
          </tr>
        </table>
      </div>
      <div class="t4 pane">
        <div>
          <table id="dailyAverage" cellpadding="0" cellspacing="0">
              <?php 
        $column = 0;
        for ($i = 6; $i > 0; $i--) {
            $tmonth_start = date('Y-m-01 00:00:00', strtotime("{$i} months ago"));
            $tmonth_end = date('Y-m-01 00:00:00', strtotime($i - 1 . " months ago"));
            $tmonth_total = totalFromRange($tmonth_start, $tmonth_end);
            $tmonth_days = date('t', strtotime("{$i} months ago"));
            ?>
                <?php 
            if ($tmonth_total != "") {
                ?>
              <thead>
                <tr>
                  <th class="left" colspan="2">
                  <?php 
                echo date('F, Y', strtotime("{$i} months ago"));
                ?>
                  </th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td><?php 
                _e('Total Income', 'cart66');
                ?>
:</td>
                  <td class="right"><strong><?php 
                echo Cart66Common::currency($tmonth_total);
                ?>
</strong></td>
                </tr>
                <tr>
                  <td><?php 
                _e('Daily Average', 'cart66');
                ?>
:</td>
                  <td class="right"><strong><?php 
                echo Cart66Common::currency($tmonth_total / $tmonth_days);
                ?>
</strong></td>
                </tr>
                </tbody>
                <?php 
            }
        }
        $ystart = date("Y-01-01 00:00:00");
        $yend = date("Y-01-01 00:00:00", strtotime("next year"));
        $year_total = totalFromRange($ystart, $yend);
        $day_of_year = date('z');
        ?>
              <thead>
                <tr>
                  <th class="left" colspan="2">YTD - <?php 
        echo date('Y');
        ?>
</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td><?php 
        _e('Total Income', 'cart66');
        ?>
:</td>
                  <td class="right"><strong><?php 
        echo Cart66Common::currency($year_total);
        ?>
</strong></td>
                </tr>
                <tr>
                    <td><?php 
        _e('Daily Average', 'cart66');
        ?>
:</td>
                    <td class="right"><strong><?php 
        echo Cart66Common::currency($year_total / $day_of_year);
        ?>
</strong></td>
                </tr>
              </tbody>
          </table>
        </div>
      </div>
      <div class="t5 pane">
        <table id="estimatedSummary" cellspacing="0" cellpadding="0">
          <tbody>
            <tr>
              <td>
                <?php 
        _e('Today', 'cart66');
        ?>
:
              </td>
              <td class="right">
                <?php 
        echo date(get_option('date_format'), strtotime('now'));
        ?>
              </td>
            </tr>
            <tr>
              <td>
                <?php 
        _e('Total Days in', 'cart66');
        ?>
 <?php 
        echo date("F", strtotime('now'));
        ?>
:
              </td>
              <td class="right">
                <?php 
        echo $total_days;
        ?>
              </td>
            </tr>
            <tr>
              <td>
                <?php 
        _e('Remaining Days in', 'cart66');
        ?>
 <?php 
        echo date("F", strtotime('now'));
        ?>
:
              </td>
              <td class="right">
                <?php 
        echo $total_days - date('j', strtotime('now'));
        ?>
              </td>
            </tr>
            <tr>
              <td>
                <?php 
        _e('Estimated Remaining Income', 'cart66');
        ?>
:
              </td>
              <td class="right">
                <?php 
        echo Cart66Common::currency(($total_days - date('j', strtotime('now'))) * $daily_avg);
        ?>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
    <script type="text/javascript">
      (function($){
        $(document).ready(function(){
          
          /* API method to get paging information */
          $.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
          {
              return {
                  "iStart":         oSettings._iDisplayStart,
                  "iEnd":           oSettings.fnDisplayEnd(),
                  "iLength":        oSettings._iDisplayLength,
                  "iTotal":         oSettings.fnRecordsTotal(),
                  "iFilteredTotal": oSettings.fnRecordsDisplay(),
                  "iPage":          Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
                  "iTotalPages":    Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
              };
          }

          /* Bootstrap style pagination control */
          $.extend( $.fn.dataTableExt.oPagination, {
              "bootstrap": {
                  "fnInit": function( oSettings, nPaging, fnDraw ) {
                      var oLang = oSettings.oLanguage.oPaginate;
                      var fnClickHandler = function ( e ) {
                          e.preventDefault();
                          if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) {
                              fnDraw( oSettings );
                          }
                      };

                      $(nPaging).addClass('pagination').append(
                          '<ul>'+
                              '<li class="prev disabled"><a href="#">&larr; '+oLang.sPrevious+'</a></li>'+
                              '<li class="next disabled"><a href="#">'+oLang.sNext+' &rarr; </a></li>'+
                          '</ul>'
                      );
                      var els = $('a', nPaging);
                      $(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler );
                      $(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler );
                  },

                  "fnUpdate": function ( oSettings, fnDraw ) {
                      var iListLength = 5;
                      var oPaging = oSettings.oInstance.fnPagingInfo();
                      var an = oSettings.aanFeatures.p;
                      var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);

                      if ( oPaging.iTotalPages < iListLength) {
                          iStart = 1;
                          iEnd = oPaging.iTotalPages;
                      }
                      else if ( oPaging.iPage <= iHalf ) {
                          iStart = 1;
                          iEnd = iListLength;
                      } else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) {
                          iStart = oPaging.iTotalPages - iListLength + 1;
                          iEnd = oPaging.iTotalPages;
                      } else {
                          iStart = oPaging.iPage - iHalf + 1;
                          iEnd = iStart + iListLength - 1;
                      }

                      for ( i=0, iLen=an.length ; i<iLen ; i++ ) {
                          // Remove the middle elements
                          $('li:gt(0)', an[i]).filter(':not(:last)').remove();

                          // Add the new list items and their event handlers
                          for ( j=iStart ; j<=iEnd ; j++ ) {
                              sClass = (j==oPaging.iPage+1) ? 'class="active"' : '';
                              $('<li '+sClass+'><a href="#">'+j+'</a></li>')
                                  .insertBefore( $('li:last', an[i])[0] )
                                  .bind('click', function (e) {
                                      e.preventDefault();
                                      oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength;
                                      fnDraw( oSettings );
                                  } );
                          }

                          // Add / remove disabled classes from the static elements
                          if ( oPaging.iPage === 0 ) {
                              $('li:first', an[i]).addClass('disabled');
                          } else {
                              $('li:first', an[i]).removeClass('disabled');
                          }

                          if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) {
                              $('li:last', an[i]).addClass('disabled');
                          } else {
                              $('li:last', an[i]).removeClass('disabled');
                          }
                      }
                  }
              }
          } );
          
          
          $('#productTable').dataTable({
            "bProcessing": true,
            "bServerSide": true,
            "bPagination": true,
            "bLengthChange": false,
            "iDisplayLength": 6,
            "sPaginationType": "bootstrap",
            "sAjaxSource": ajaxurl + "?action=dashboard_products_table",
            "aoColumns": [
              { "sClass": "left" },
              { "sClass": "center" },
              { "sClass": "right" },
            ],
            "oLanguage": { 
              "sZeroRecords": "<?php 
        _e('No matching Products found', 'cart66');
        ?>
", 
              "sSearch": "<?php 
        _e('Search', 'cart66');
        ?>
:", 
              "sInfo": "<?php 
        _e('Showing', 'cart66');
        ?>
 _START_ <?php 
        _e('to', 'cart66');
        ?>
 _END_ <?php 
        _e('of', 'cart66');
        ?>
 _TOTAL_ <?php 
        _e('entries', 'cart66');
        ?>
", 
              "sInfoEmpty": "<?php 
        _e('Showing 0 to 0 of 0 entries', 'cart66');
        ?>
", 
              "oPaginate": {
                "sNext": "<?php 
        _e('Next', 'cart66');
        ?>
", 
                "sPrevious": "<?php 
        _e('Previous', 'cart66');
        ?>
", 
                "sLast": "<?php 
        _e('Last', 'cart66');
        ?>
", 
                "sFirst": "<?php 
        _e('First', 'cart66');
        ?>
"
              }, 
              "sInfoFiltered": "(<?php 
        _e('filtered from', 'cart66');
        ?>
 _MAX_ <?php 
        _e('total entries', 'cart66');
        ?>
)", 
              "sLengthMenu": "<?php 
        _e('Show', 'cart66');
        ?>
 _MENU_ <?php 
        _e('entries', 'cart66');
        ?>
", 
              "sLoadingRecords": "<?php 
        _e('Loading', 'cart66');
        ?>
...", 
              "sProcessing": "<?php 
        _e('Processing', 'cart66');
        ?>
..." 
            }
          });
        })
      })(jQuery);
    </script> 
    <script type="text/javascript">
      (function($){
        $(document).ready(function() {
          // setting the tabs in the sidebar hide and show, setting the current tab
          $('div.pane').hide();
          $('div.t1').show();
          $('div.loading').hide();
          $('div.cart66Tabbed ul.tabs li.t1 a').addClass('tab-current');
          // SIDEBAR TABS
          $('div.cart66Tabbed ul li a, div.t1 a, div.t1 tr.summaryDetails').click(function(){
            if($(this).hasClass('tab')) {
              var thisClass = this.className.slice(0,2);
              $('div.pane').hide();
              $('div.' + thisClass).fadeIn(300);
              $('div.cart66Tabbed ul.tabs li a').removeClass('tab-current');
              $('div.cart66Tabbed ul.tabs li a.' + thisClass).addClass('tab-current');
            }
          });
        });
      })(jQuery);
    </script><?php 
    }
コード例 #11
0
 public function isEffective()
 {
     $isEffective = false;
     $startPromo = strtotime($this->effective_from);
     $endPromo = strtotime($this->effective_to);
     $date = Cart66Common::localTs();
     if (empty($this->effective_from) || $this->effective_from == "0000-00-00 00:00:00") {
         $startPromo = strtotime("-1 year");
     }
     if (empty($this->effective_to) || $this->effective_to == "0000-00-00 00:00:00") {
         $endPromo = strtotime("+1 year");
     }
     if ($date < $endPromo && $date > $startPromo) {
         $isEffective = true;
     }
     return $isEffective;
 }
コード例 #12
0
 for ($i = 1; $i <= 12; $i++) {
     $val = $i;
     if (strlen($val) == 1) {
         $val = '0' . $i;
     }
     $selected = '';
     if (isset($p['cardExpirationMonth']) && $val == $p['cardExpirationMonth']) {
         $selected = 'selected="selected"';
     }
     echo "<option value='{$val}' {$selected}>{$val}</option>\n";
 }
 ?>
         </select> / <select id="payment-cardExpirationYear" name="payment[cardExpirationYear]">
           <option value=''></option>
           <?php 
 $year = date('Y', Cart66Common::localTs());
 for ($i = $year; $i <= $year + 12; $i++) {
     $selected = '';
     if (isset($p['cardExpirationYear']) && $i == $p['cardExpirationYear']) {
         $selected = 'selected="selected"';
     }
     echo "<option value='{$i}' {$selected}>{$i}</option>\n";
 }
 ?>
         </select>
       
       </li>
       
       <li>
         <label for="payment-securityId"><?php 
 _e('Security ID', 'cart66');
コード例 #13
0
 /**
  * Cancel remote PayPal subscription and set local status to canceled.
  * If expire is set to true, also change the active until date to today.
  * 
  * @param string $note The note to send to PayPal describing the reason for cancelation
  * @param boolean $expire If true, change the active_until date to today
  */
 public function cancelPayPalSubscription($note = 'Your subscription has been canceled per your request.', $expire = false)
 {
     if ($this->id > 0) {
         $pp = new Cart66PayPalPro();
         $profileId = $this->paypalBillingProfileId;
         $pp->ManageRecurringPaymentsProfileStatus($profileId, 'Cancel', $note);
         $this->active = 0;
         $this->status = 'canceled';
         if ($expire) {
             $this->activeUntil = date('Y-m-d 00:00:00', Cart66Common::localTs());
         }
         $this->save();
     }
 }
コード例 #14
0
 public function saveTcoOrder()
 {
     global $wpdb;
     // NEW Parse custom value
     $referrer = false;
     $ouid = $_POST['custom'];
     if (strpos($ouid, '|') !== false) {
         list($ouid, $referrer) = explode('|', $ouid);
     }
     $order = new Cart66Order();
     $order->loadByOuid($ouid);
     if ($order->id > 0 && $order->status == 'checkout_pending' && $_POST['total'] == $order->total) {
         $statusOptions = Cart66Common::getOrderStatusOptions();
         $status = $statusOptions[0];
         $data = array('bill_first_name' => $_POST['first_name'], 'bill_last_name' => $_POST['last_name'], 'bill_address' => $_POST['street_address'], 'bill_address2' => $_POST['street_address2'], 'bill_city' => $_POST['city'], 'bill_state' => $_POST['state'], 'bill_zip' => $_POST['zip'], 'bill_country' => $_POST['country'], 'email' => $_POST['email'], 'trans_id' => $_POST['order_number'], 'ordered_on' => date('Y-m-d H:i:s', Cart66Common::localTs()), 'status' => $status);
         // Verify the first items in the IPN are for products managed by Cart66. It could be an IPN from some other type of transaction.
         $productsTable = Cart66Common::getTableName('products');
         $orderItemsTable = Cart66Common::getTableName('order_items');
         $sql = "SELECT id from {$productsTable} where item_number = '" . $_POST['li_0_product_id'] . "'";
         $productId = $wpdb->get_var($sql);
         if (!$productId) {
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] about to throw an exception, this is not an IPN that should be managed by cart66 because the item number does not match up");
             throw new Exception("This is not an IPN that should be managed by Cart66");
         }
         $order->setData($data);
         $order->save();
         $orderId = $order->id;
         // Handle email receipts
         if (CART66_PRO && CART66_EMAILS && Cart66Setting::getValue('enable_advanced_notifications') == 1) {
             $notify = new Cart66AdvancedNotifications($orderId);
             $notify->sendAdvancedEmailReceipts();
         } elseif (CART66_EMAILS) {
             $notify = new Cart66Notifications($orderId);
             $notify->sendEmailReceipts();
         }
         // Process affiliate reward if necessary
         if ($referrer && CART66_PRO) {
             Cart66Common::awardCommission($order->id, $referrer);
             // End processing affiliate information
             if (isset($_COOKIE['ap_id']) && $_COOKIE['ap_id']) {
                 setcookie('ap_id', $referrer, time() - 3600, "/");
                 unset($_COOKIE['ap_id']);
             }
             Cart66Session::drop('app_id');
         }
         if (CART66_PRO) {
             // Begin iDevAffiliate Tracking
             if (CART66_PRO && ($url = Cart66Setting::getValue('idevaff_url'))) {
                 require_once CART66_PATH . "/pro/idevaffiliate-award.php";
             }
             // End iDevAffiliate Tracking
         }
         wp_redirect(remove_query_arg('listener', Cart66Common::getCurrentPageUrl()));
         exit;
     }
 }
コード例 #15
0
 $orderInfo['bill_address2'] = '';
 $orderInfo['bill_city'] = '';
 $orderInfo['bill_state'] = '';
 $orderInfo['bill_zip'] = '';
 $orderInfo['phone'] = preg_replace("/[^0-9]/", "", $details['PHONENUM']);
 $orderInfo['email'] = $details['EMAIL'];
 $orderInfo['coupon'] = $promoMsg;
 $orderInfo['tax'] = isset($response['TAXAMT']) ? $response['TAXAMT'] : '';
 $orderInfo['shipping'] = Cart66Session::get('Cart66Cart')->getShippingCost();
 $orderInfo['subtotal'] = Cart66Session::get('Cart66Cart')->getSubTotal();
 $taxAmt = isset($response['TAXAMT']) ? $response['TAXAMT'] : '';
 $orderInfo['total'] = number_format(Cart66Session::get('Cart66Cart')->getGrandTotal() + $taxAmt, 2, '.', '');
 $orderInfo['non_subscription_total'] = number_format(Cart66Session::get('Cart66Cart')->getNonSubscriptionAmount(), 2, '.', '');
 $orderInfo['trans_id'] = $response['TRANSACTIONID'];
 $orderInfo['status'] = $status;
 $orderInfo['ordered_on'] = date('Y-m-d H:i:s', Cart66Common::localTs());
 $orderInfo['shipping_method'] = Cart66Session::get('Cart66Cart')->getShippingMethodName();
 if ($account) {
     $orderInfo['account_id'] = $account->id;
 } else {
     $orderInfo['account_id'] = 0;
 }
 $orderId = Cart66Session::get('Cart66Cart')->storeOrder($orderInfo);
 Cart66Session::set('order_id', $orderId);
 $receiptLink = Cart66Common::getPageLink('store/receipt');
 $newOrder = new Cart66Order($orderId);
 // Send email receipts
 if (CART66_PRO && CART66_EMAILS && Cart66Setting::getValue('enable_advanced_notifications') == 1) {
     $notify = new Cart66AdvancedNotifications($orderId);
     $notify->sendAdvancedEmailReceipts();
 } elseif (CART66_EMAILS) {
コード例 #16
0
 /**
  * Save a PayPal IPN order from a Website Payments Pro cart sale.
  *
  * @param array $pp Urldecoded array of IPN key value pairs
  */
 public function saveOrder($pp)
 {
     global $wpdb;
     // NEW Parse custom value
     $referrer = false;
     $ouid = $pp['custom'];
     if (strpos($ouid, '|') !== false) {
         list($ouid, $referrer, $gfData) = explode('|', $ouid);
     }
     $order = new Cart66Order();
     $order->loadByOuid($ouid);
     if ($order->id > 0 && $order->status == 'checkout_pending') {
         $hasDigital = false;
         // Calculate subtotal
         $subtotal = 0;
         $numCartItems = $pp['num_cart_items'] > 0 ? $pp['num_cart_items'] : 1;
         for ($i = 1; $i <= $numCartItems; $i++) {
             // PayPal in not consistent in the way it passes back the item amounts
             $amt = 0;
             if (isset($pp['mc_gross' . $i])) {
                 $amt = $pp['mc_gross' . $i];
             } elseif (isset($pp['mc_gross_' . $i])) {
                 $amt = $pp['mc_gross_' . $i];
             }
             $subtotal += $amt;
         }
         $statusOptions = Cart66Common::getOrderStatusOptions();
         $status = $statusOptions[0];
         // Parse Gravity Forms ids
         $gfIds = array();
         if (!empty($gfData)) {
             $forms = explode(',', $gfData);
             foreach ($forms as $f) {
                 list($itemId, $formEntryId) = explode(':', $f);
                 $gfIds[$itemId] = $formEntryId;
             }
         }
         // Look for discount amount
         $discount = 0;
         if (isset($pp['discount'])) {
             $discount = $pp['discount'];
         }
         $data = array('bill_first_name' => $pp['first_name'], 'bill_last_name' => $pp['last_name'], 'bill_address' => $pp['address_street'], 'bill_city' => $pp['address_city'], 'bill_state' => $pp['address_state'], 'bill_zip' => $pp['address_zip'], 'bill_country' => $pp['address_country'], 'ship_first_name' => $pp['address_name'], 'ship_address' => $pp['address_street'], 'ship_city' => $pp['address_city'], 'ship_state' => $pp['address_state'], 'ship_zip' => $pp['address_zip'], 'ship_country' => $pp['address_country'], 'email' => $pp['payer_email'], 'phone' => $pp['contact_phone'], 'shipping' => $pp['mc_handling'], 'tax' => $pp['tax'], 'subtotal' => $subtotal, 'total' => $pp['mc_gross'], 'discount_amount' => $discount, 'trans_id' => $pp['txn_id'], 'ordered_on' => date('Y-m-d H:i:s', Cart66Common::localTs()), 'status' => $status);
         foreach ($data as $key => $value) {
             $data[$key] = is_null($value) ? '' : $value;
         }
         // Verify the first items in the IPN are for products managed by Cart66. It could be an IPN from some other type of transaction.
         $productsTable = Cart66Common::getTableName('products');
         $orderItemsTable = Cart66Common::getTableName('order_items');
         $sql = "SELECT id from {$productsTable} where item_number = '" . $pp['item_number1'] . "'";
         $productId = $wpdb->get_var($sql);
         if (!$productId) {
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] about to throw an exception, this is not an IPN that should be managed by cart66 because the item number does not match up");
             throw new Exception("This is not an IPN that should be managed by Cart66");
         }
         // Look for the 100% coupons shipping item and move it back to a shipping costs rather than a product
         if ($data['shipping'] == 0) {
             for ($i = 1; $i <= $numCartItems; $i++) {
                 $itemNumber = strtoupper($pp['item_number' . $i]);
                 if ($itemNumber == 'SHIPPING') {
                     $data['shipping'] = isset($pp['mc_gross_' . $i]) ? $pp['mc_gross_' . $i] : $pp['mc_gross' . $i];
                 }
             }
         }
         $order->setData($data);
         $order->save();
         $orderId = $order->id;
         // Handle email receipts
         if (CART66_PRO && CART66_EMAILS && Cart66Setting::getValue('enable_advanced_notifications') == 1) {
             $notify = new Cart66AdvancedNotifications($orderId);
             $notify->sendAdvancedEmailReceipts();
         } elseif (CART66_EMAILS) {
             $notify = new Cart66Notifications($orderId);
             $notify->sendEmailReceipts();
         }
         // Process affiliate reward if necessary
         if ($referrer && CART66_PRO) {
             Cart66Common::awardCommission($order->id, $referrer);
             // End processing affiliate information
             if (isset($_COOKIE['ap_id']) && $_COOKIE['ap_id']) {
                 setcookie('ap_id', $referrer, time() - 3600, "/");
                 unset($_COOKIE['ap_id']);
             }
             Cart66Session::drop('app_id');
         }
         if (CART66_PRO) {
             // Begin iDevAffiliate Tracking
             if (CART66_PRO && ($url = Cart66Setting::getValue('idevaff_url'))) {
                 require_once CART66_PATH . "/pro/idevaffiliate-award.php";
             }
             // End iDevAffiliate Tracking
         }
     } else {
         $orderTable = Cart66Common::getTableName('orders');
         // Make sure the transaction id is not already in the database
         $sql = "SELECT count(*) as c from {$orderTable} where trans_id=%s";
         $sql = $wpdb->prepare($sql, $pp['txn_id']);
         $count = $wpdb->get_var($sql);
         if ($count < 1) {
             $hasDigital = false;
             // Calculate subtotal
             $subtotal = 0;
             $numCartItems = $pp['num_cart_items'] > 0 ? $pp['num_cart_items'] : 1;
             for ($i = 1; $i <= $numCartItems; $i++) {
                 // PayPal in not consistent in the way it passes back the item amounts
                 $amt = 0;
                 if (isset($pp['mc_gross' . $i])) {
                     $amt = $pp['mc_gross' . $i];
                 } elseif (isset($pp['mc_gross_' . $i])) {
                     $amt = $pp['mc_gross_' . $i];
                 }
                 $subtotal += $amt;
             }
             $statusOptions = Cart66Common::getOrderStatusOptions();
             $status = $statusOptions[0];
             $ouid = md5($pp['txn_id'] . $pp['address_street']);
             // Parse custom value
             $referrer = false;
             $deliveryMethod = $pp['custom'];
             if (strpos($deliveryMethod, '|') !== false) {
                 list($deliveryMethod, $referrer, $gfData, $coupon) = explode('|', $deliveryMethod);
             }
             // Parse Gravity Forms ids
             $gfIds = array();
             if (!empty($gfData)) {
                 $forms = explode(',', $gfData);
                 foreach ($forms as $f) {
                     list($itemId, $formEntryId) = explode(':', $f);
                     $gfIds[$itemId] = $formEntryId;
                 }
             }
             // Look for discount amount
             $discount = 0;
             if (isset($pp['discount'])) {
                 $discount = $pp['discount'];
             }
             // Look for coupon code
             $coupon_code = "none";
             if (isset($coupon) && $coupon != "") {
                 $coupon_code = $coupon;
             }
             $data = array('bill_first_name' => $pp['first_name'], 'bill_last_name' => $pp['last_name'], 'bill_address' => $pp['address_street'], 'bill_city' => $pp['address_city'], 'bill_state' => $pp['address_state'], 'bill_zip' => $pp['address_zip'], 'bill_country' => $pp['address_country'], 'ship_first_name' => $pp['address_name'], 'ship_address' => $pp['address_street'], 'ship_city' => $pp['address_city'], 'ship_state' => $pp['address_state'], 'ship_zip' => $pp['address_zip'], 'ship_country' => $pp['address_country'], 'shipping_method' => $deliveryMethod, 'email' => $pp['payer_email'], 'phone' => $pp['contact_phone'], 'shipping' => $pp['mc_handling'], 'tax' => $pp['tax'], 'subtotal' => $subtotal, 'total' => $pp['mc_gross'], 'coupon' => $coupon_code, 'discount_amount' => $discount, 'trans_id' => $pp['txn_id'], 'ordered_on' => date('Y-m-d H:i:s', Cart66Common::localTs()), 'status' => $status, 'ouid' => $ouid);
             $data = Cart66Common::deNullArrayValues($data);
             // Verify the first items in the IPN are for products managed by Cart66. It could be an IPN from some other type of transaction.
             $productsTable = Cart66Common::getTableName('products');
             $orderItemsTable = Cart66Common::getTableName('order_items');
             $sql = "SELECT id from {$productsTable} where item_number = '" . $pp['item_number1'] . "'";
             $productId = $wpdb->get_var($sql);
             if (!$productId) {
                 throw new Exception("This is not an IPN that should be managed by Cart66");
             }
             // Look for the 100% coupons shipping item and move it back to a shipping costs rather than a product
             if ($data['shipping'] == 0) {
                 for ($i = 1; $i <= $numCartItems; $i++) {
                     $itemNumber = strtoupper($pp['item_number' . $i]);
                     if ($itemNumber == 'SHIPPING') {
                         $data['shipping'] = isset($pp['mc_gross_' . $i]) ? $pp['mc_gross_' . $i] : $pp['mc_gross' . $i];
                     }
                 }
             }
             $wpdb->insert($orderTable, $data);
             $orderId = $wpdb->insert_id;
             $product = new Cart66Product();
             for ($i = 1; $i <= $numCartItems; $i++) {
                 $sql = "SELECT id from {$productsTable} where item_number = '" . $pp['item_number' . $i] . "'";
                 $productId = $wpdb->get_var($sql);
                 if ($productId > 0) {
                     $product->load($productId);
                     // Decrement inventory
                     $info = $pp['item_name' . $i];
                     if (strpos($info, '(') > 0) {
                         $info = strrchr($info, '(');
                         $start = strpos($info, '(');
                         $end = strpos($info, ')');
                         $length = $end - $start;
                         $variation = substr($info, $start + 1, $length - 1);
                         Cart66Common::log("PayPal Variation Information: {$variation}\n{$info}");
                     }
                     $qty = $pp['quantity' . $i];
                     Cart66Product::decrementInventory($productId, $variation, $qty);
                     if ($hasDigital == false) {
                         $hasDigital = $product->isDigital();
                     }
                     // PayPal is not consistent in the way it passes back the item amounts
                     $amt = 0;
                     if (isset($pp['mc_gross' . $i])) {
                         $amt = $pp['mc_gross' . $i];
                     } elseif (isset($pp['mc_gross_' . $i])) {
                         $amt = $pp['mc_gross_' . $i] / $pp['quantity' . $i];
                     }
                     // Look for Gravity Form Entry ID
                     $formEntryId = '';
                     if (is_array($gfIds) && !empty($gfIds) && isset($gfIds[$i])) {
                         $formEntryId = $gfIds[$i];
                         if (class_exists('RGFormsModel')) {
                             if ($lead = RGFormsModel::get_lead($formEntryId)) {
                                 $lead['status'] = 'active';
                                 RGFormsModel::update_lead($lead);
                             }
                         }
                     }
                     $duid = md5($pp['txn_id'] . '-' . $orderId . '-' . $productId);
                     $data = array('order_id' => $orderId, 'product_id' => $productId, 'item_number' => $pp['item_number' . $i], 'product_price' => $amt, 'description' => $pp['item_name' . $i], 'quantity' => $pp['quantity' . $i], 'duid' => $duid, 'form_entry_ids' => $formEntryId);
                     $wpdb->insert($orderItemsTable, $data);
                 }
             }
             // Handle email receipts
             if (CART66_PRO && CART66_EMAILS && Cart66Setting::getValue('enable_advanced_notifications') == 1) {
                 $notify = new Cart66AdvancedNotifications($orderId);
                 $notify->sendAdvancedEmailReceipts();
             } elseif (CART66_EMAILS) {
                 $notify = new Cart66Notifications($orderId);
                 $notify->sendEmailReceipts();
             }
             $promotion = new Cart66Promotion();
             $promotion->loadByCode($coupon_code);
             if ($promotion) {
                 $promotion->updateRedemptions();
             }
             // Process affiliate reward if necessary
             if ($referrer) {
                 Cart66Common::awardCommission($orderId, $referrer);
             }
         }
         // end transaction id check
     }
 }
コード例 #17
0
 protected function _update()
 {
     if (isset($this->_data['updated_at'])) {
         $this->_data['updated_at'] = date('Y-m-d H:i:s', Cart66Common::localTs());
     }
     $this->_db->update($this->_tableName, $this->_data, array('id' => $this->_data['id']));
     return $this->id;
 }
コード例 #18
0
 public function attachMembershipProduct($product, $firstName = null, $lastName = null)
 {
     if ($this->id > 0 && $product->isMembershipProduct()) {
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Attaching a membership product to account: {$this->id}");
         $firstName = isset($firstName) ? $firstName : $this->firstName;
         $lastName = isset($lastName) ? $lastName : $this->lastName;
         $data = array('account_id' => $this->id, 'billing_first_name' => $firstName, 'billing_last_name' => $lastName, 'subscription_plan_name' => $product->name, 'feature_level' => $product->featureLevel, 'status' => 'active', 'active' => 1, 'product_id' => $product->id);
         $duration = '+ ' . $product->billingInterval . ' ' . $product->billingIntervalUnit;
         if ($product->lifetimeMembership == 1) {
             $data['lifetime'] = 1;
         } else {
             $data['active_until'] = date('Y-m-d H:i:s', strtotime($duration));
         }
         // Look for extension or upgrade
         if ($subscription = $this->getCurrentAccountSubscription()) {
             if ($subscription->featureLevel == $product->featureLevel && $product->lifetimeMembership != 1) {
                 // Extend active_until date to prevent overlapping duration intervals
                 $data['active_until'] = date('Y-m-d H:i:s', strtotime($subscription->activeUntil . $duration, Cart66Common::localTs()));
             }
             // Expire current subscription
             $subscription->status = 'canceled';
             $subscription->active = 0;
             $subscription->activeUntil = date('Y-m-d 00:00:00', Cart66Common::localTs());
             $subscription->save();
         }
         $subscription = new Cart66AccountSubscription();
         $subscription->setData($data);
         $subscription->save();
     }
 }
コード例 #19
0
ファイル: reports.php プロジェクト: rbredow/allyzabbacart
        $data['days'][$i] = date('m/d/Y', strtotime($dayStart, Cart66Common::localTs()));
        $data['totals'][$i] = $dailyTotal;
    }
    ?>
<table class="Cart66TableMed">
  <?php 
    for ($i = 0; $i < count($data['days']); $i++) {
        ?>
    <?php 
        if ($i % 7 == 0) {
            echo '<tr>';
        }
        ?>
    <td>
      <span style="color: #999; font-size: 11px;"><?php 
        echo date(get_option('date_format'), strtotime($data['days'][$i], Cart66Common::localTs()));
        ?>
</span><br/>
      <?php 
        echo Cart66Common::currency($data['totals'][$i]);
        ?>
    </td>
    <?php 
        if ($i % 7 == 6) {
            echo '</tr>';
        }
        ?>
  <?php 
    }
    ?>
</table>
コード例 #20
0
 public static function getTimeLeft($datestamp)
 {
     $output = false;
     if (!empty($datestamp) && $datestamp != '0000-00-00 00:00:00') {
         $timeleft = strtotime($datestamp) - Cart66Common::localTs();
         if (Cart66Common::localTs() == strtotime($datestamp)) {
             $output = __('Now', 'cart66');
         } elseif ($days = floor($timeleft / 86400)) {
             $timeleft = $timeleft % 86400;
             $output = date(get_option('date_format'), strtotime($datestamp));
         } elseif ($hours = floor($timeleft / 3600)) {
             $timeleft = $timeleft % 3600;
             $output = $hours . ' ' . _n('hour', 'hours', $hours, 'cart66') . __(" to go", "cart66");
         } elseif ($minutes = floor($timeleft / 60)) {
             $timeleft = $timeleft % 60;
             $output = $minutes . ' ' . _n('minute', 'minutes', $minutes, 'cart66') . __(" to go", "cart66");
         } elseif ($seconds = floor($timeleft / 1)) {
             $timeleft = $timeleft % 1;
             $output = $seconds . ' ' . _n('second', 'seconds', $seconds, 'cart66') . __(" to go", "cart66");
         }
     }
     return $output;
 }
コード例 #21
0
 public static function getSalesForMonth()
 {
     $thisMonth = Cart66Common::localTs();
     $year = date('Y', "{$thisMonth}");
     $month = date('n', "{$thisMonth}");
     $orders = Cart66Common::getTableName('orders');
     $orderItems = Cart66Common::getTableName('order_items');
     $products = Cart66Common::getTableName('products');
     $start = date('Y-m-d 00:00:00', strtotime($month . '/1/' . $year));
     $end = date('Y-m-d 00:00:00', strtotime($month . '/1/' . $year . ' +1 month'));
     $sql = "SELECT \n        oi.id, \n        oi.description, \n        oi.product_id, \n        oi.product_price, \n        o.ordered_on,\n        oi.quantity\n      from \n        {$products} as p,\n        {$orders} as o, \n        {$orderItems} as oi \n      where\n        oi.product_id = p.id and\n        oi.order_id = o.id and\n        o.ordered_on >= '{$start}' and \n        o.ordered_on < '{$end}'\n    ";
     global $wpdb;
     $results = $wpdb->get_results($sql);
     return $results;
 }
コード例 #22
0
 /**
  * Save the session data to the database.
  * Set the last activity date and serialize the user data before 
  */
 protected static function _save()
 {
     if (self::$_validRequest) {
         self::$_data['user_data'] = serialize(self::$_userData);
         self::$_data['last_activity'] = date('Y-m-d H:i:s', Cart66Common::localTs());
         //Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Saving Session User Data: " . print_r(self::$_userData, true));
         self::$_data['id'] > 0 ? self::_update() : self::_insert();
     } else {
         $sid = isset($_COOKIE['Cart66DBSID']) ? $_COOKIE['Cart66DBSID'] : false;
         $reqInfo = "\nCart66DBSID: {$sid}\nREQUEST: " . $_SERVER['REQUEST_URI'] . "\nQUERY STRING: " . $_SERVER['QUERY_STRING'];
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Not saving session because the request is being ignored {$reqInfo}");
     }
 }
コード例 #23
0
 /**
  * Create a recurring payments profile
  * The initial payment is charged with DoExpressCheckout so that the first payment is received immediately
  */
 public function CreateRecurringPaymentsProfile($token, $cartItem, $index)
 {
     $plan = new Cart66PayPalSubscription($cartItem->getPayPalSubscriptionId());
     $queryString = array('TOKEN' => $token, 'METHOD' => 'CreateRecurringPaymentsProfile', 'PROFILESTARTDATE' => date('Y-m-d\\Tg:i:s', strtotime($plan->getStartTimeFormula(), Cart66Common::localTs())), 'BILLINGPERIOD' => ucwords(rtrim($plan->billingIntervalUnit, 's')), 'BILLINGFREQUENCY' => $plan->billingInterval, 'TOTALBILLINGCYCLES' => $plan->billingCycles, 'AMT' => $plan->price, 'INITAMT' => 0, 'CURRENCYCODE' => CURRENCY_CODE, 'FAILEDINITAMTACTION' => 'CancelOnFailure', 'L_BILLINGTYPE' . $index => 'RecurringPayments', 'DESC' => $plan->name . ' ' . str_replace('&nbsp;', ' ', strip_tags($plan->getPriceDescription($plan->offerTrial > 0, '(trial)'))));
     if ($plan->offerTrial == 1) {
         $queryString['TRIALBILLINGPERIOD'] = ucwords(rtrim($plan->trialPeriodUnit, 's'));
         $queryString['TRIALBILLINGFREQUENCY'] = $plan->trialPeriod;
         $queryString['TRIALAMT'] = $plan->trialPrice;
         $queryString['TRIALTOTALBILLINGCYCLES'] = $plan->trialCycles;
     }
     $params = array();
     $queryString = array_merge($this->_apiData, $queryString);
     foreach ($queryString as $key => $value) {
         $params[] = $key . '=' . urlencode($value);
     }
     $nvp = implode('&', $params);
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Creating recurring payments profile NVP: " . str_replace('&', "\n", $nvp));
     $result = $this->_decodeNvp($this->_sendRequest($this->_apiEndPoint, $nvp));
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Creating recurring payments raw result: " . print_r($result, true));
     return $result;
 }
コード例 #24
0
 public static function dailyGravityFormsOrphanedEntryRemoval()
 {
     if (class_exists('RGFormsModel') && !Cart66Setting::getValue('keep_orphaned_gravity_entries')) {
         $forms = RGFormsModel::get_forms();
         $delete_leads = array();
         foreach ($forms as $form) {
             $leads = RGFormsModel::get_leads($form->id, 0, 'DESC', '', 0, 30, null, null, false, null, null, $status = 'unpaid');
             foreach ($leads as $lead) {
                 if (strtotime($lead['date_created']) < strtotime('24 hours ago', Cart66Common::localTs())) {
                     $delete_leads[] = $lead['id'];
                 }
             }
         }
         RGFormsModel::delete_leads($delete_leads);
     }
 }