本文整理汇总了PHP中Cart66Common::deNullArrayValues方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart66Common::deNullArrayValues方法的具体用法?PHP Cart66Common::deNullArrayValues怎么用?PHP Cart66Common::deNullArrayValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart66Common
的用法示例。
在下文中一共展示了Cart66Common::deNullArrayValues方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveEmailLog
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');
$data = Cart66Common::deNullArrayValues($data);
$wpdb->insert($logTable, $data);
$emailLogId = $wpdb->insert_id;
Cart66Common::log("Saved email log ({$emailLogId}): " . $data['status'] . "\nSQL: " . $wpdb->last_query . ' ' . Cart66Common::localTs());
}
}
示例2: saveOrder
//.........这里部分代码省略.........
$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;
示例3: saveOrder
/**
* 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;
}
示例4: saveMijirehOrder
public function saveMijirehOrder($order_number)
{
global $wpdb;
// Make sure the order is not already in the database
$orders_table = Cart66Common::getTableName('orders');
$sql = "select id from {$orders_table} where trans_id = %s";
$sql = $wpdb->prepare($sql, $order_number);
$order_id = $wpdb->get_var($sql);
if (!$order_id) {
// Save the order
$order = new Cart66Order();
$cloud_order = $this->pullOrder($order_number);
$order_data = $this->buildOrderDataArray($cloud_order);
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Order data: " . print_r($order_data, true));
$order_data = Cart66Common::deNullArrayValues($order_data);
$order_id = $order->rawSave($order_data);
// Save the order items
$order_items_table = Cart66Common::getTableName('order_items');
foreach ($cloud_order['items'] as $key => $item) {
$product = new Cart66Product();
$product->loadByItemNumber($item['sku']);
$data = array('order_id' => $order_id, 'product_id' => $product->id, 'product_price' => $item['price'], 'item_number' => $item['sku'], 'description' => $item['name'], 'quantity' => $item['quantity'], 'duid' => md5($order_id . $item['sku']));
// Look for gravity forms data
if (isset($cloud_order['meta_data'][$key]['gforms_' . $item['sku']])) {
$data['form_entry_ids'] = $cloud_order['meta_data'][$key]['gforms_' . $item['sku']];
}
$fIds = array();
if (isset($data['form_entry_ids'])) {
$fIds = explode(',', $data['form_entry_ids']);
if (is_array($fIds) && count($fIds)) {
foreach ($fIds as $entryId) {
if (class_exists('RGFormsModel')) {
if ($lead = RGFormsModel::get_lead($entryId)) {
$lead['status'] = 'active';
RGFormsModel::update_lead($lead);
}
}
}
}
}
$data = Cart66Common::deNullArrayValues($data);
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Trying to save this order item:" . print_r($data, true));
$wpdb->insert($order_items_table, $data);
$order_item_id = $wpdb->insert_id;
// Decrement inventory after sale
if (Cart66Setting::getValue('track_inventory') == 1) {
$option_info = '';
if (isset($cloud_order['meta_data']['options_' . $item['sku']])) {
$option_info = $cloud_order['meta_data']['options_' . $item['sku']];
}
Cart66Product::decrementInventory($data['product_id'], $option_info, $data['quantity']);
}
// Look for membership product upgrades/extensions
if (isset($cloud_order['meta_data']['account_id']) && is_numeric($cloud_order['meta_data']['account_id'])) {
$order->load($order_id);
$account_id = $cloud_order['meta_data']['account_id'];
if ($mp = $order->getMembershipProduct()) {
$account = new Cart66Account();
$account->load($account_id);
$account->attachMembershipProduct($mp, $account->firstName, $account->lastName);
$order->account_id = $account->id;
$order->save();
}
}
}
//update the number of redemptions for the promotion code.
if (Cart66Session::get('Cart66Promotion')) {
Cart66Session::get('Cart66Promotion')->updateRedemptions();
}
// Send email receipts
if (CART66_PRO && CART66_EMAILS && Cart66Setting::getValue('enable_advanced_notifications') == 1) {
$notify = new Cart66AdvancedNotifications($order_id);
$notify->sendAdvancedEmailReceipts();
} elseif (CART66_EMAILS) {
$notify = new Cart66Notifications($order_id);
$notify->sendEmailReceipts();
}
//Cart66Common::sendEmailReceipts($order_id);
}
// Redirect to receipt page
$this->goToReceipt($order_id);
}