示例#1
0
 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;
 }
 public function gravityFormToCart($entry)
 {
     if (CART66_PRO) {
         $formId = Cart66GravityReader::getGravityFormIdForEntry($entry['id']);
         if ($formId) {
             $productId = Cart66Product::getProductIdByGravityFormId($formId);
             if ($productId > 0) {
                 $product = new Cart66Product($productId);
                 $qty = $product->gravityCheckForEntryQuantity($entry);
                 $options = $product->gravityGetVariationPrices($entry);
                 $productUrl = Cart66Common::getCurrentPageUrl();
                 $cart = Cart66Session::get('Cart66Cart');
                 $item = $cart->addItem($productId, $qty, $options, $entry['id'], $productUrl, false, true);
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Cart Item Value: " . print_r($item, true));
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Should we use the gravity forms price? " . $product->gravity_form_pricing . ' :: Session value: ' . Cart66Session::get('userPrice_' . $product->id));
                 if ($product->gravity_form_pricing == 1) {
                     $price = Cart66GravityReader::getPrice($entry['id']) / $qty;
                     $entry_id = $item->getFirstFormEntryId();
                     $user_price_name = 'userPrice_' . $productId . '_' . $entry_id;
                     Cart66Session::set($user_price_name, $price, true);
                     // Setting the price of a Gravity Forms pricing product
                     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Using gravity forms pricing for product: Price: {$price} :: Name: " . $product->name . " :: Session variable name: {$user_price_name}");
                 }
                 $cartPage = get_page_by_path('store/cart');
                 $cartPageLink = get_permalink($cartPage->ID);
                 Cart66Session::set('Cart66LastPage', $_SERVER['HTTP_REFERER']);
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Cart66 Session Dump: " . Cart66Session::dump());
                 if (!Cart66Setting::getValue('display_form_entries_before_sale')) {
                     $entry["status"] = 'unpaid';
                 }
                 RGFormsModel::update_lead($entry);
                 $cart->applyAutoPromotions();
                 do_action('cart66_after_add_to_cart', $product, $qty);
                 wp_redirect($cartPageLink);
                 exit;
             }
         }
     }
 }
            <?php 
    if (class_exists('RGForms')) {
        ?>
              <li>
                <label class="med" for="subscription-gravity_form_id"><?php 
        _e('Attach Gravity Form', 'cart66');
        ?>
:</label>
                <select name='subscription[gravity_form_id]' id="subscription-gravity_form_id">
                  <option value='0'><?php 
        _e('None', 'cart66');
        ?>
</option>
                  <?php 
        global $wpdb;
        $gfIdsInUse = Cart66GravityReader::getIdsInUse();
        $gfTitles = array();
        $forms = Cart66Common::getTableName('rg_form', '');
        $sql = "SELECT id, title from {$forms} where is_active=1 order by title";
        $results = $wpdb->get_results($sql);
        foreach ($results as $r) {
            $disabled = in_array($r->id, $gfIdsInUse) ? 'disabled="disabled"' : '';
            $gfTitles[$r->id] = $r->title;
            $selected = $data['subscription']->gravityFormId == $r->id ? 'selected="selected"' : '';
            echo "<option value='{$r->id}' {$selected} {$disabled}>{$r->title}</option>";
        }
        ?>
                </select>
                <span class="label_desc"><?php 
        _e('A Gravity Form may only be linked to one product', 'cart66');
        ?>
        <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;
        echo 'style="display:none;"';
    }
    ?>
>
                  <label class="long"><?php 
    _e('Quantity field', 'cart66');
    ?>
:</label>
                  <select name="product[gravity_form_qty_id]" id="product-gravity_form_qty_id">
                    <option value='0'><?php 
    _e('None', 'cart66');
    ?>
</option>
                    <?php 
    try {
        $gr = new Cart66GravityReader($product->gravityFormId);
        $fields = $gr->getStandardFields();
        foreach ($fields as $id => $label) {
            $id = str_replace("'", "", $id);
            Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Gravity Form Fields :: {$id} => {$label}");
            $selected = $product->gravityFormQtyId == $id ? 'selected="selected"' : '';
            echo "<option value='{$id}' {$selected}>{$label}</option>\n";
        }
    } catch (Cart66Exception $e) {
        $exception = Cart66Exception::exceptionMessages($e->getCode(), $e->getMessage());
        $gravityError = Cart66Common::getView('views/error-messages.php', $exception);
    }
    ?>
                  </select>
                  <?php 
    echo isset($gravityError) ? $gravityError : '';
         $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";
示例#7
0
 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;
 }
 public static function updateGravityProductQuantityField()
 {
     $formId = Cart66Common::getVal('formId');
     $gr = new Cart66GravityReader($formId);
     $fields = $gr->getStandardFields();
     header('Content-type: application/json');
     echo json_encode($fields);
     die;
 }
     $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";
         }
示例#10
0
        ?>
    <?php 
        echo do_shortcode("[gravityform id=" . $data['gravity_form_id'] . " ajax=false] ");
        ?>
  <?php 
    } else {
        ?>
    
    <?php 
        if (Cart66Product::checkInventoryLevelForProduct($data['product']->id) == 0) {
            $soldOutLabel = Cart66Setting::getValue('label_out_of_stock') ? strtolower(Cart66Setting::getValue('label_out_of_stock')) : __('out of stock', 'cart66');
            ?>
      
      <div class="alert-message alert-error Cart66Unavailable">
        We're sorry but <?php 
            echo Cart66GravityReader::getFormTitle($data['gravity_form_id']);
            ?>
 is currently <?php 
            echo $soldOutLabel;
            ?>
.
      </div>
      
  <?php 
        }
        ?>
    
<?php 
    }
} elseif ($data['showPrice'] == 'only') {
    ?>
示例#11
0
    ?>
</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'>&nbsp;</td>
      </tr>
 /**
  * Return a stdClass object with the price difference and a CSV list of options.
  *   $optionResult->priceDiff
  *   $optionResult->options
  * @return object
  */
 protected function _processOptionInfo($product, $optionInfo)
 {
     $valid_options = array();
     if ($product->isGravityProduct()) {
         $valid_options = Cart66GravityReader::getFormValuesArray($product->gravity_form_id);
     } else {
         if (strlen($product->options_1) > 1) {
             $valid_options[] = explode(',', str_replace(' ', '', $product->options_1));
         }
         if (strlen($product->options_2) > 1) {
             $valid_options[] = explode(',', str_replace(' ', '', $product->options_2));
         }
     }
     $optionInfo = trim($optionInfo);
     $priceDiff = 0;
     $options = explode('~', $optionInfo);
     $optionList = array();
     foreach ($options as $opt) {
         if (strlen($opt) >= 1) {
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Working with option: {$opt}\n" . print_r($valid_options, true));
             // make sure product option is vallid
             $is_gravity_form = false;
             $check_option = str_replace(' ', '', $opt);
             if ($is_gravity_form = $product->isGravityProduct()) {
                 $check_option = explode('|', $check_option);
                 $check_option = $check_option[0];
             }
             if ($this->_validate_option($valid_options, $check_option, $is_gravity_form)) {
                 if (strpos($opt, '$')) {
                     if (preg_match('/\\+\\s*\\$/', $opt)) {
                         $opt = preg_replace('/\\+\\s*\\$/', '+' . CART66_CURRENCY_SYMBOL_TEXT, $opt);
                         list($opt, $pd) = explode('+' . CART66_CURRENCY_SYMBOL_TEXT, $opt);
                         $optionList[] = trim($opt);
                         $priceDiff += $pd;
                     } elseif (preg_match('/-\\s*\\$/', $opt)) {
                         $opt = preg_replace('/-\\s*\\$/', '-' . CART66_CURRENCY_SYMBOL_TEXT, $opt);
                         list($opt, $pd) = explode('-' . CART66_CURRENCY_SYMBOL_TEXT, $opt);
                         $optionList[] = trim($opt);
                         $pd = trim($pd);
                         $priceDiff -= $pd;
                     } else {
                         $optionList[] = trim($opt);
                     }
                 } else {
                     if (preg_match('/\\+\\s*\\' . CART66_CURRENCY_SYMBOL_TEXT . '/', $opt)) {
                         $opt = preg_replace('/\\+\\s*\\' . CART66_CURRENCY_SYMBOL_TEXT . '/', '+' . CART66_CURRENCY_SYMBOL_TEXT, $opt);
                         list($opt, $pd) = explode('+' . CART66_CURRENCY_SYMBOL_TEXT, $opt);
                         $optionList[] = trim($opt);
                         $priceDiff += $pd;
                     } elseif (preg_match('/-\\s*\\' . CART66_CURRENCY_SYMBOL_TEXT . '/', $opt)) {
                         $opt = preg_replace('/-\\s*\\' . CART66_CURRENCY_SYMBOL_TEXT . '/', '-' . CART66_CURRENCY_SYMBOL_TEXT, $opt);
                         list($opt, $pd) = explode('-' . CART66_CURRENCY_SYMBOL_TEXT, $opt);
                         $optionList[] = trim($opt);
                         $pd = trim($pd);
                         $priceDiff -= $pd;
                     } else {
                         $optionList[] = trim($opt);
                     }
                 }
             } else {
                 throw new Exception("Invalid product option: {$opt}");
             }
         } else {
             if (count($valid_options) > 0 && !$product->isGravityProduct()) {
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] no option");
                 throw new Exception("Product option is required");
             }
         }
     }
     $optionResult = new stdClass();
     $optionResult->priceDiff = $priceDiff;
     $optionResult->options = implode(', ', $optionList);
     return $optionResult;
 }
 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;
 }
 public static function increaseInventory($id, $variation = '', $qty = 1)
 {
     Cart66Common::log("Increasing Inventory: line " . __LINE__);
     // Build varation ikey string component
     if (!empty($variation)) {
         $variation = self::scrubVaritationsForIkey(str_replace(', ', '~', $variation));
     }
     $p = new Cart66Product($id);
     $is_gravity_form = false;
     $valid_options = array();
     if ($p->isGravityProduct()) {
         $valid_options = Cart66GravityReader::getFormValuesArray($p->gravity_form_id);
         $is_gravity_form = true;
     } else {
         if (strlen($p->options_1) > 1) {
             $valid_options[] = explode(',', str_replace(' ', '', $p->options_1));
         }
         if (strlen($p->options_2) > 1) {
             $valid_options[] = explode(',', str_replace(' ', '', $p->options_2));
         }
     }
     $newVariation = '';
     $options = explode(',', $variation);
     foreach ($options as $option) {
         if ($p->validate_option($valid_options, $option, $is_gravity_form)) {
             $newVariation .= $option;
         }
     }
     $ikey = $p->getInventoryKey($newVariation);
     $count = $p->getInventoryCount($ikey);
     $newCount = $count + $qty;
     $p->setInventoryLevel($ikey, $newCount);
 }