public static function exportOrders($startDate, $endDate) { global $wpdb; $start = date('Y-m-d 00:00:00', strtotime($startDate)); $end = date('Y-m-d 00:00:00', strtotime($endDate . ' + 1 day')); $orders = Cart66Common::getTableName('orders'); $items = Cart66Common::getTableName('order_items'); $orderHeaders = array('id' => __('Order ID', 'cart66'), 'trans_id' => __('Order Number', 'cart66'), 'ordered_on' => __('Date', 'cart66'), 'bill_first_name' => __('Billing First Name', 'cart66'), 'bill_last_name' => __('Billing Last Name', 'cart66'), 'bill_address' => __('Billing Address', 'cart66'), 'bill_address2' => __('Billing Address 2', 'cart66'), 'bill_city' => __('Billing City', 'cart66'), 'bill_state' => __('Billing State', 'cart66'), 'bill_country' => __('Billing Country', 'cart66'), 'bill_zip' => __('Billing Zip Code', 'cart66'), 'ship_first_name' => __('Shipping First Name', 'cart66'), 'ship_last_name' => __('Shipping Last Name', 'cart66'), 'ship_address' => __('Shipping Address', 'cart66'), 'ship_address2' => __('Shipping Address 2', 'cart66'), 'ship_city' => __('Shipping City', 'cart66'), 'ship_state' => __('Shipping State', 'cart66'), 'ship_country' => __('Shipping Country', 'cart66'), 'ship_zip' => __('Shipping Zip Code', 'cart66'), 'phone' => __('Phone', 'cart66'), 'email' => __('Email', 'cart66'), 'coupon' => __('Coupon', 'cart66'), 'discount_amount' => __('Discount Amount', 'cart66'), 'shipping' => __('Shipping Cost', 'cart66'), 'subtotal' => __('Subtotal', 'cart66'), 'tax' => __('Tax', 'cart66'), 'total' => __('Total', 'cart66'), 'ip' => __('IP Address', 'cart66'), 'shipping_method' => __('Delivery Method', 'cart66'), 'status' => __('Order Status', 'cart66')); $orderColHeaders = implode(',', $orderHeaders); $orderColSql = implode(',', array_keys($orderHeaders)); $out = $orderColHeaders . ",Form Data,Item Number,Description,Quantity,Product Price,Form ID\n"; $sql = "SELECT {$orderColSql} from {$orders} where ordered_on >= %s AND ordered_on < %s AND status != %s order by ordered_on"; $sql = $wpdb->prepare($sql, $start, $end, 'checkout_pending'); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] SQL: {$sql}"); $selectedOrders = $wpdb->get_results($sql, ARRAY_A); foreach ($selectedOrders as $o) { $itemRowPrefix = '"' . $o['id'] . '","' . $o['trans_id'] . '",' . str_repeat(',', count($o) - 3); $orderId = $o['id']; $sql = "SELECT form_entry_ids, item_number, description, quantity, product_price FROM {$items} where order_id = {$orderId}"; Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Item query: {$sql}"); $selectedItems = $wpdb->get_results($sql, ARRAY_A); $out .= '"' . implode('","', $o) . '"'; $printItemRowPrefix = false; if (!empty($selectedItems)) { foreach ($selectedItems as $i) { if ($printItemRowPrefix) { $out .= $itemRowPrefix; } if ($i['form_entry_ids'] && CART66_PRO) { $i['form_id'] = $i['form_entry_ids']; $GReader = new Cart66GravityReader(); $i['form_entry_ids'] = $GReader->displayGravityForm($i['form_entry_ids'], true); $i['form_entry_ids'] = str_replace("\"", "''", $i['form_entry_ids']); } $i['description'] = str_replace(",", " -", $i['description']); $out .= ',"' . implode('","', $i) . '"'; $out .= "\n"; $printItemRowPrefix = true; } } else { $out .= "\n"; } } Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Report\n{$out}"); return $out; }
<td><?php echo Cart66Common::currency($item->product_price); ?> </td> <td><?php echo Cart66Common::currency($item->product_price * $item->quantity); ?> </td> </tr> <?php if (!empty($item->form_entry_ids)) { $entries = explode(',', $item->form_entry_ids); foreach ($entries as $entryId) { if (class_exists('RGFormsModel')) { if (RGFormsModel::get_lead($entryId)) { echo "<tr><td colspan='4'><div class='Cart66GravityFormDisplay'>" . Cart66GravityReader::displayGravityForm($entryId) . "</div></td></tr>"; } } else { echo "<tr><td colspan='5' style='color: #955;'>" . __('This order requires Gravity Forms in order to view all of the order information', 'cart66') . "</td></tr>"; } } } ?> <?php if (Cart66Setting::getValue('enable_google_analytics') == 1 && $order->viewed == 0) { ?> <script type="text/javascript"> /* <![CDATA[ */ _gaq.push(['_addItem', '<?php echo $order->trans_id;
$hasDigital = $product->isDigital(); } $price = $item->product_price * $item->quantity; // $msg .= "Item: " . $item->item_number . ' ' . $item->description . "\n"; $msg .= __("Item", "cart66") . ": "; if (Cart66Setting::getValue('display_item_number_receipt')) { $msg .= $item->item_number . ' '; } $msg .= $item->description . "\n"; if ($item->quantity > 1) { $msg .= __("Quantity", "cart66") . ": " . $item->quantity . "\n"; } $msg .= __("Item Price", "cart66") . ": " . Cart66Common::currency($item->product_price, false) . "\n"; $msg .= __("Item Total", "cart66") . ": " . Cart66Common::currency($item->product_price * $item->quantity, false) . "\n\n"; if ($product->isGravityProduct()) { $msg .= Cart66GravityReader::displayGravityForm($item->form_entry_ids, true); } } if ($order->shipping_method != 'None' && $order->shipping_method != 'Download') { $msg .= __("Shipping", "cart66") . ": " . Cart66Common::currency($order->shipping, false) . "\n"; } if (!empty($order->coupon) && $order->coupon != 'none') { $msg .= __("Coupon", "cart66") . ": " . $order->coupon . "\n"; } if ($order->tax > 0) { $msg .= __("Tax", "cart66") . ": " . Cart66Common::currency($order->tax, false) . "\n"; } $msg .= "\n" . __("TOTAL", "cart66") . ": " . Cart66Common::currency($order->total, false) . "\n"; if ($order->shipping_method != 'None' && $order->shipping_method != 'Download') { $msg .= "\n\n" . __("SHIPPING INFORMATION", "cart66") . "\n\n"; $msg .= $order->ship_first_name . ' ' . $order->ship_last_name . "\n";
public function showAttachedForms($fullMode) { $out = ''; if (is_array($this->_formEntryIds)) { foreach ($this->_formEntryIds as $entryId) { /* $removeLink = ''; if($fullMode) { $removeLink = str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); $removeLink .= strpos($removeLink, '?') ? '&' : '?'; $removeLink .= 'cart66-task=remove-attached-form&entry=' . $entryId; $removeLink = '<a class="Cart66RemoveFormLink" href="' . $removeLink . '">remove</a>'; } */ $out .= "<div class='Cart66GravityFormDisplay'>" . Cart66GravityReader::displayGravityForm($entryId) . "</div>"; } } return $out; }
$product = new Cart66Product(); $product->load($item->product_id); $fulfillmentProducts = explode(',', $orderFulfillment->products); foreach ($fulfillmentProducts as $prod) { if ($prod == $item->product_id) { if (Cart66Setting::getValue('display_item_number_receipt')) { $msg .= $item->item_number . ' '; } $msg .= "<b>" . $item->description . "</b>\n"; $msg .= __('Quantity: ', 'cart66') . $item->quantity . "\n"; if (!empty($item->form_entry_ids)) { $entries = explode(',', $item->form_entry_ids); foreach ($entries as $entryId) { if (class_exists('RGFormsModel')) { if (RGFormsModel::get_lead($entryId)) { echo Cart66GravityReader::displayGravityForm($entryId, true, true); } } } } } } } if ($order->shipping_method != 'None') { if ($order->hasShippingInfo()) { $msg .= "\n\n" . __("SHIPPING INFORMATION", "cart66") . "\n\n"; $msg .= $order->ship_first_name . ' ' . $order->ship_last_name . "\n"; $msg .= $order->ship_address . "\n"; if (!empty($order->ship_address2)) { $msg .= $order->ship_address2 . "\n"; }
?> </td> <td style="text-align: right;"><?php echo Cart66Common::currency($item->product_price * $item->quantity); ?> </td> </tr> <?php if (!empty($item->form_entry_ids)) { $entries = explode(',', $item->form_entry_ids); $wpurl = get_bloginfo('wpurl'); foreach ($entries as $entryId) { if (class_exists('RGFormsModel')) { if (RGFormsModel::get_lead($entryId)) { $formId = Cart66GravityReader::getGravityFormIdForEntry($entryId); echo "<tr><td colspan='5'>" . Cart66GravityReader::displayGravityForm($entryId) . "</td></tr>"; echo "<tr><td colspan='5' align='right' style='padding-bottom: 5px !important; '><a style='font-size: 10px;' href='" . $wpurl . "/wp-admin/admin.php?page=gf_entries&view=entry&id=" . $formId . "&lid=" . $entryId . "'>View Gravity Forms Entry</a></td></tr>"; } } else { echo "<tr><td colspan='5' style='color: #955;'>" . __("This order requires Gravity Forms in order to view all of the order information", "cart66") . "</td></tr>"; } } } ?> <?php } ?> <tr> <td colspan='4'> </td> </tr>
public function defaultPlainEmailMessage($order) { $msg = __("ORDER NUMBER", "cart66") . ": " . $order->trans_id . "\n\n"; $hasDigital = false; $product = new Cart66Product(); foreach ($order->getItems() as $item) { $product->load($item->product_id); if ($hasDigital == false) { $hasDigital = $product->isDigital(); } $price = $item->product_price * $item->quantity; // $msg .= "Item: " . $item->item_number . ' ' . $item->description . "\n"; $msg .= __("Item", "cart66") . ": " . $item->description . "\n"; if ($hasDigital) { $receiptPage = get_page_by_path('store/receipt'); $receiptPageLink = get_permalink($receiptPage); $receiptPageLink .= strstr($receiptPageLink, '?') ? '&duid=' . $item->duid : '?duid=' . $item->duid; $msg .= "\n" . $receiptPageLink . "\n"; } if ($item->quantity > 1) { $msg .= __("Quantity", "cart66") . ": " . $item->quantity . "\n"; } $msg .= __("Item Price", "cart66") . ": " . Cart66Common::currency($item->product_price, false) . "\n"; $msg .= __("Item Total", "cart66") . ": " . Cart66Common::currency($item->product_price * $item->quantity, false) . "\n\n"; if ($product->isGravityProduct()) { $msg .= Cart66GravityReader::displayGravityForm($item->form_entry_ids, true); } } if ($order->shipping_method != 'None' && $order->shipping_method != 'Download') { $msg .= __("Shipping", "cart66") . ": " . Cart66Common::currency($order->shipping, false) . "\n"; } if (!empty($order->coupon) && $order->coupon != 'none') { $msg .= __("Coupon", "cart66") . ": " . $order->coupon . "\n"; } if ($order->tax > 0) { $msg .= __("Tax", "cart66") . ": " . Cart66Common::currency($order->tax, false) . "\n"; } $msg .= "\n" . __("TOTAL", "cart66") . ": " . Cart66Common::currency($order->total, false) . "\n"; if ($order->shipping_method != 'None' && $order->shipping_method != 'Download') { $msg .= "\n\n" . __("SHIPPING INFORMATION", "cart66") . "\n\n"; $msg .= $order->ship_first_name . ' ' . $order->ship_last_name . "\n"; $msg .= $order->ship_address . "\n"; if (!empty($order->ship_address2)) { $msg .= $order->ship_address2 . "\n"; } $msg .= $order->ship_city . ' ' . $order->ship_state . ' ' . $order->ship_zip . "\n" . $order->ship_country . "\n"; if (is_array($additional_fields = maybe_unserialize($order->additional_fields)) && isset($additional_fields['shipping'])) { foreach ($additional_fields['shipping'] as $af) { $msg .= html_entity_decode($af['label']) . ': ' . $af['value'] . "\n"; } } $msg .= "\n" . __("Delivery via", "cart66") . ": " . $order->shipping_method . "\n"; } $msg .= "\n\n" . __("BILLING INFORMATION", "cart66") . "\n\n"; $msg .= $order->bill_first_name . ' ' . $order->bill_last_name . "\n"; $msg .= $order->bill_address . "\n"; if (!empty($order->bill_address2)) { $msg .= $order->bill_address2 . "\n"; } $msg .= $order->bill_city . ' ' . $order->bill_state; $msg .= $order->bill_zip != null ? ', ' : ' '; $msg .= $order->bill_zip . "\n" . $order->bill_country . "\n"; if (is_array($additional_fields = maybe_unserialize($order->additional_fields)) && isset($additional_fields['billing'])) { foreach ($additional_fields['billing'] as $af) { $msg .= html_entity_decode($af['label']) . ': ' . $af['value'] . "\n"; } } if (!empty($order->phone)) { $phone = Cart66Common::formatPhone($order->phone); $msg .= "\n" . __("Phone", "cart66") . ": {$phone}\n"; } if (!empty($order->email)) { $msg .= __("Email", "cart66") . ': ' . $order->email . "\n"; } if (is_array($additional_fields = maybe_unserialize($order->additional_fields)) && isset($additional_fields['payment'])) { foreach ($additional_fields['payment'] as $af) { $msg .= html_entity_decode($af['label']) . ': ' . $af['value'] . "\n"; } } if (isset($order->custom_field) && $order->custom_field != '') { if (Cart66Setting::getValue('checkout_custom_field_label')) { $msg .= "\n" . Cart66Setting::getValue('checkout_custom_field_label'); } else { $msg .= "\n" . __('Enter any special instructions you have for this order:', 'cart66'); } $msg .= "\n" . $order->custom_field . "\n"; } $receiptPage = get_page_by_path('store/receipt'); $link = get_permalink($receiptPage->ID); if (strstr($link, "?")) { $link .= '&ouid=' . $order->ouid; } else { $link .= '?ouid=' . $order->ouid; } if ($hasDigital) { $msg .= "\n" . __('DOWNLOAD LINK', 'cart66') . "\n" . __('Click the link below to download your order.', 'cart66') . "\n{$link}"; } else { $msg .= "\n" . __('VIEW RECEIPT ONLINE', 'cart66') . "\n" . __('Click the link below to view your receipt online.', 'cart66') . "\n{$link}"; } $msgIntro = Cart66Setting::getValue('receipt_intro') && !Cart66Setting::getValue('enable_advanced_notifications') ? Cart66Setting::getValue('receipt_intro') : ''; $msgIntro .= Cart66Setting::getValue('receipt_message_intro') && Cart66Setting::getValue('enable_advanced_notifications') ? Cart66Setting::getValue('receipt_plain_email') : ''; $msg = $msgIntro . " \n----------------------------------\n\n" . $msg; return $msg; }