当前位置: 首页>>代码示例>>PHP>>正文


PHP wpsc_get_state_by_id函数代码示例

本文整理汇总了PHP中wpsc_get_state_by_id函数的典型用法代码示例。如果您正苦于以下问题:PHP wpsc_get_state_by_id函数的具体用法?PHP wpsc_get_state_by_id怎么用?PHP wpsc_get_state_by_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wpsc_get_state_by_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_gateway_data

 public function get_gateway_data()
 {
     if (!($this->gateway_data = wp_cache_get($this->log_id, 'wpsc_checkout_form_gateway_data'))) {
         $map = array('firstname' => 'first_name', 'lastname' => 'last_name', 'address' => 'street', 'city' => 'city', 'state' => 'state', 'country' => 'country', 'postcode' => 'zip', 'phone' => 'phone');
         foreach (array('shipping', 'billing') as $type) {
             $data_key = "{$type}_address";
             $this->gateway_data[$data_key] = array();
             foreach ($map as $key => $new_key) {
                 $key = $type . $key;
                 if (isset($this->data[$key])) {
                     $value = $this->data[$key];
                     if ($new_key == 'state' && is_numeric($value)) {
                         $value = wpsc_get_state_by_id($value, 'code');
                     }
                     $this->gateway_data[$data_key][$new_key] = $value;
                 }
             }
             $name = isset($this->gateway_data[$data_key]['first_name']) ? $this->gateway_data[$data_key]['first_name'] . ' ' : '';
             $name .= isset($this->gateway_data[$data_key]['last_name']) ? $this->gateway_data[$data_key]['last_name'] : '';
             $this->gateway_data[$data_key]['name'] = trim($name);
         }
         wp_cache_set($this->log_id, $this->gateway_data, 'wpsc_checkout_form_gateway_data');
     }
     return apply_filters('wpsc_checkout_form_gateway_data', $this->gateway_data, $this->log_id);
 }
开发者ID:dreamteam111,项目名称:dreamteam,代码行数:25,代码来源:checkout-form-data.class.php

示例2: collate_data

 /**
  * collate_data method, collate purchase data, like addresses, like country
  * @access public
  */
 function collate_data()
 {
     global $wpdb;
     // get purchase data, regardless of being fed the ID or the sessionid
     if ($this->purchase_id > 0) {
         $purchase_id =& $this->purchase_id;
         $purchase_logs = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = {$purchase_id} LIMIT 1", ARRAY_A);
     } else {
         if ($this->session_id != null) {
             $purchase_logs = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` = {$this->session_id} LIMIT 1", ARRAY_A);
             $this->purchase_id = $purchase_logs['id'];
             $purchase_id =& $this->purchase_id;
         }
     }
     $email_address = $wpdb->get_var("SELECT `value` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` AS `form_field` INNER JOIN `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` AS `collected_data` ON `form_field`.`id` = `collected_data`.`form_id` WHERE `form_field`.`type` IN ( 'email' ) AND `collected_data`.`log_id` IN ( '{$purchase_id}' )");
     $currency_code = $wpdb->get_var("SELECT `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`='" . get_option('currency_type') . "' LIMIT 1");
     $collected_form_data = $wpdb->get_results("SELECT `data_names`.`id`, `data_names`.`unique_name`, `collected_data`.`value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` AS `collected_data` JOIN `" . WPSC_TABLE_CHECKOUT_FORMS . "` AS `data_names` ON `collected_data`.`form_id` = `data_names`.`id` WHERE `log_id` = '" . $purchase_id . "'", ARRAY_A);
     $address_keys = array('billing' => array('first_name' => 'billingfirstname', 'last_name' => 'billinglastname', 'address' => 'billingaddress', 'city' => 'billingcity', 'state' => 'billingstate', 'country' => 'billingcountry', 'post_code' => 'billingpostcode'), 'shipping' => array('first_name' => 'shippingfirstname', 'last_name' => 'shippinglastname', 'address' => 'shippingaddress', 'city' => 'shippingcity', 'state' => 'shippingstate', 'country' => 'shippingcountry', 'post_code' => 'shippingpostcode'));
     $address_data = array('billing' => array(), 'shipping' => array());
     foreach ((array) $collected_form_data as $collected_form_row) {
         $address_data_set = 'billing';
         $address_key = array_search($collected_form_row['unique_name'], $address_keys['billing']);
         if ($address_key == null) {
             $address_data_set = 'shipping';
             //					exit('<pre>'.print_r($collected_form_row,true).'</pre>');
             $address_key = array_search($collected_form_row['unique_name'], $address_keys['shipping']);
         }
         if ($address_key == null) {
             continue;
         }
         if ($collected_form_row['unique_name'] == 'billingcountry' || $collected_form_row['unique_name'] == 'shippingcountry') {
             $country = maybe_unserialize($collected_form_row['value']);
             $address_data[$address_data_set][$address_key] = $country[0];
         } elseif ($collected_form_row['unique_name'] == 'shippingstate') {
             $address_data[$address_data_set][$address_key] = wpsc_get_state_by_id($collected_form_row['value'], 'code');
         } else {
             $address_data[$address_data_set][$address_key] = $collected_form_row['value'];
         }
     }
     //		exit('<pre>'.print_r($address_data,true).'</pre>');
     if (count($address_data['shipping']) < 1) {
         $address_data['shipping'] = $address_data['billing'];
     }
     $this->cart_data = array('software_name' => 'WP e-Commerce/' . WPSC_PRESENTABLE_VERSION . '', 'store_location' => get_option('base_country'), 'store_currency' => $currency_code, 'is_subscription' => false, 'has_discounts' => false, 'notification_url' => add_query_arg('wpsc_action', 'gateway_notification', get_option('siteurl') . "/index.php"), 'transaction_results_url' => get_option('transact_url'), 'shopping_cart_url' => get_option('shopping_cart_url'), 'products_page_url' => get_option('product_list_url'), 'base_shipping' => $purchase_logs['base_shipping'], 'total_price' => $purchase_logs['totalprice'], 'session_id' => $purchase_logs['sessionid'], 'transaction_id' => $purchase_logs['transaction_id'], 'email_address' => $email_address, 'billing_address' => $address_data['billing'], 'shipping_address' => $address_data['shipping']);
 }
开发者ID:alx,项目名称:SBek-Arak,代码行数:49,代码来源:merchant.class.php

示例3: get_shipping_xml

 /**
  * Builds XML API request for Shipping Rates API
  * 	 *
  * @uses apply_filters - filters XML on return
  * @todo Get ZIP as transient when #437 is complete
  * @since 3.8.9
  * @return string $xml
  */
 public static function get_shipping_xml()
 {
     global $wpsc_cart;
     $zip = wpsc_get_customer_meta('shipping_zip');
     $state = wpsc_get_state_by_id($wpsc_cart->delivery_region, 'code');
     $country = $wpsc_cart->delivery_country;
     $products = $wpsc_cart->cart_items;
     $products_xml = '';
     $num = 0;
     if (count($products)) {
         foreach ($products as $product) {
             if (!$product->uses_shipping) {
                 continue;
             }
             $products_xml .= '<Item num="' . $num . '">';
             $products_xml .= '<Code>' . wpsc_esc_xml($product->sku) . '</Code>';
             $products_xml .= '<Quantity>' . wpsc_esc_xml($product->quantity) . '</Quantity>';
             $products_xml .= '</Item>';
             $num++;
         }
     }
     if (empty($products_xml)) {
         return '';
     }
     $xml = '<?xml version="1.0" encoding="utf-8"?>';
     $xml .= '<RateRequest>';
     $xml .= '<Username>' . wpsc_esc_xml(self::$email) . '</Username>';
     $xml .= '<Password>' . wpsc_esc_xml(self::$passwd) . '</Password>';
     $xml .= '<Order>';
     $xml .= '<AddressInfo type="ship">';
     $xml .= '<State>' . wpsc_esc_xml($state) . '</State>';
     $xml .= '<Country>' . wpsc_esc_xml($country) . '</Country>';
     $xml .= '<Zip>' . wpsc_esc_xml($zip) . '</Zip>';
     $xml .= '</AddressInfo>';
     $xml .= $products_xml;
     $xml .= '</Order>';
     $xml .= '</RateRequest>';
     return apply_filters('get_shipping_xml', $xml);
 }
开发者ID:ashik968,项目名称:digiplot,代码行数:47,代码来源:shipwire_functions.php

示例4: transaction_results


//.........这里部分代码省略.........
            $report = str_replace('%total_price%', $total_price_email, $report);
            $report = str_replace('%shop_name%', get_option('blogname'), $report);
            $report = str_replace('%find_us%', $purchase_log['find_us'], $report);
            $message_html = str_replace('%product_list%', $product_list_html, $message_html);
            $message_html = str_replace('%total_shipping%', $total_shipping_html, $message_html);
            $message_html = str_replace('%total_price%', $total_price_email, $message_html);
            $message_html = str_replace('%shop_name%', get_option('blogname'), $message_html);
            $message_html = str_replace('%find_us%', $purchase_log['find_us'], $message_html);
            //$message_html = str_replace('%order_status%',get_option('blogname'),$message_html);
            if ($email != '' && $purchase_log['email_sent'] != 1) {
                add_filter('wp_mail_from', 'wpsc_replace_reply_address', 0);
                add_filter('wp_mail_from_name', 'wpsc_replace_reply_name', 0);
                if ($purchase_log['processed'] < 2) {
                    $payment_instructions = strip_tags(get_option('payment_instructions'));
                    $message = __('Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc') . "\n\r" . $payment_instructions . "\n\r" . $message;
                    wp_mail($email, __('Order Pending: Payment Required', 'wpsc'), $message);
                } else {
                    wp_mail($email, __('Purchase Receipt', 'wpsc'), $message);
                }
            }
            remove_filter('wp_mail_from_name', 'wpsc_replace_reply_name');
            remove_filter('wp_mail_from', 'wpsc_replace_reply_address');
            $report_user = __('Customer Details', 'wpsc') . "\n\r";
            $report_user .= "Billing Info \n\r";
            foreach ((array) $thepurchlogitem->userinfo as $userinfo) {
                if ($userinfo['unique_name'] != 'billingcountry') {
                    $report_user .= "" . $userinfo['name'] . ": " . $userinfo['value'] . "\n";
                } else {
                    $userinfo['value'] = maybe_unserialize($userinfo['value']);
                    if (is_array($userinfo['value'])) {
                        if (!empty($userinfo['value'][1]) && !is_numeric($userinfo['value'][1])) {
                            $report_user .= "State: " . $userinfo['value'][1] . "\n";
                        } elseif (is_numeric($userinfo['value'][1])) {
                            $report_user .= "State: " . wpsc_get_state_by_id($userinfo['value'][1], 'name') . "\n";
                        }
                        if (!empty($userinfo['value'][0])) {
                            $report_user .= "Country: " . $userinfo['value'][0] . "\n";
                        }
                    } else {
                        $report_user .= "" . $userinfo['name'] . ": " . $userinfo['value'] . "\n";
                    }
                }
            }
            $report_user .= "\n\rShipping Info \n\r";
            foreach ((array) $thepurchlogitem->shippinginfo as $userinfo) {
                if ($userinfo['unique_name'] != 'shippingcountry' && $userinfo['unique_name'] != 'shippingstate') {
                    $report_user .= "" . $userinfo['name'] . ": " . $userinfo['value'] . "\n";
                } elseif ($userinfo['unique_name'] == 'shippingcountry') {
                    $userinfo['value'] = maybe_unserialize($userinfo['value']);
                    if (is_array($userinfo['value'])) {
                        if (!empty($userinfo['value'][1]) && !is_numeric($userinfo['value'][1])) {
                            $report_user .= "State: " . $userinfo['value'][1] . "\n";
                        } elseif (is_numeric($userinfo['value'][1])) {
                            $report_user .= "State: " . wpsc_get_state_by_id($userinfo['value'][1], 'name') . "\n";
                        }
                        if (!empty($userinfo['value'][0])) {
                            $report_user .= "Country: " . $userinfo['value'][0] . "\n";
                        }
                    } else {
                        $report_user .= "" . $userinfo['name'] . ": " . $userinfo['value'] . "\n";
                    }
                } elseif ($userinfo['unique_name'] == 'shippingstate') {
                    if (!empty($userinfo['value']) && !is_numeric($userinfo['value'])) {
                        $report_user .= "" . $userinfo['name'] . ": " . $userinfo['value'] . "\n";
                    } elseif (is_numeric($userinfo['value'])) {
                        $report_user .= "State: " . wpsc_get_state_by_id($userinfo['value'], 'name') . "\n";
开发者ID:BGCX261,项目名称:zombie-craft-svn-to-git,代码行数:67,代码来源:transaction_result_functions.php

示例5: add_pushes

 public function add_pushes($session_id)
 {
     global $wpdb;
     $purchase = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= %s LIMIT 1", $session_id));
     $purchase_id = $purchase->id;
     $output = '';
     $city = $wpdb->get_var($wpdb->prepare("\n\t\t\t\t\t\tSELECT tf.value FROM " . WPSC_TABLE_SUBMITTED_FORM_DATA . " tf\n\t\t\t\t\t\tLEFT JOIN " . WPSC_TABLE_CHECKOUT_FORMS . " cf\n\t\t\t\t\t\tON cf.id = tf.form_id\n\t\t\t\t\t\tWHERE cf.unique_name = 'billingcity'\n\t\t\t\t\t\tAND log_id = %d", $purchase_id));
     $state = $wpdb->get_var($wpdb->prepare("\n\t\t\t\t\t\tSELECT tf.value\n\t\t\t\t\t\tFROM " . WPSC_TABLE_SUBMITTED_FORM_DATA . " tf\n\t\t\t\t\t\tLEFT JOIN " . WPSC_TABLE_CHECKOUT_FORMS . " cf\n\t\t\t\t\t\tON cf.id = tf.form_id\n\t\t\t\t\t\tWHERE cf.unique_name = 'billingstate'\n\t\t\t\t\t\tAND log_id = %d", $purchase_id));
     $country = $wpdb->get_var($wpdb->prepare("\n\t\t\t\t\t\tSELECT tf.value\n\t\t\t\t\t\tFROM " . WPSC_TABLE_SUBMITTED_FORM_DATA . " tf\n\t\t\t\t\t\tLEFT JOIN " . WPSC_TABLE_CHECKOUT_FORMS . " cf\n\t\t\t\t\t\tON cf.id = tf.form_id\n\t\t\t\t\t\tWHERE cf.unique_name = 'billingcountry'\n\t\t\t\t\t\tAND log_id = %d", $purchase_id));
     $city = !empty($city) ? $city : '';
     $state = !empty($state) ? wpsc_get_state_by_id($state, 'name') : '';
     $country = !empty($country) ? $country : '';
     $cart_items = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . WPSC_TABLE_CART_CONTENTS . " WHERE purchaseid = %d", $purchase_id), ARRAY_A);
     $total_shipping = wpsc_get_total_shipping($purchase_id);
     $total_tax = $total_price = 0;
     foreach ($cart_items as $item) {
         $total_tax += $item['tax_charged'];
         $total_price += $item['price'];
     }
     if ($this->is_theme_tracking || $this->advanced_code) {
         $output .= "<script type='text/javascript'>\n\r";
     }
     add_filter('wpsc_toggle_display_currency_code', array($this, 'remove_currency_and_html'));
     $output .= "\n\t\t\t_gaq.push(['_addTrans',\n\t\t\t'" . $purchase_id . "',                                     // order ID - required\n\t\t\t'" . wp_specialchars_decode($this->get_site_name()) . "', // affiliation or store name\n\t\t\t'" . number_format($total_price, 2, '.', '') . "',   // total - required\n\t\t\t'" . wpsc_currency_display($total_tax) . "',              // tax\n\t\t\t'" . wpsc_currency_display($total_shipping) . "',         // shipping\n\t\t\t'" . wp_specialchars_decode($city) . "',                  // city\n\t\t\t'" . wp_specialchars_decode($state) . "',                 // state or province\n\t\t\t'" . wp_specialchars_decode($country) . "'                // country\n  \t\t]);\n\r";
     remove_filter('wpsc_toggle_display_currency_code', array($this, 'remove_currency_and_html'));
     foreach ($cart_items as $item) {
         $category = wp_get_object_terms($item['prodid'], 'wpsc_product_category', array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'all_with_object_id'));
         $item['sku'] = get_post_meta($item['prodid'], '_wpsc_sku', true);
         if ($category) {
             $item['category'] = $category[0]->name;
         } else {
             $item['category'] = '';
         }
         $item = array_map('wp_specialchars_decode', $item);
         $output .= "_gaq.push(['_addItem'," . "'" . $purchase_id . "'," . "'" . $item['sku'] . "'," . "'" . $item['name'] . "'," . "'" . $item['category'] . "'," . "'" . $item['price'] . "'," . "'" . $item['quantity'] . "']);\n\r";
         // Item Quantity
     }
     $output .= "_gaq.push(['_trackTrans']);\n\r";
     if ($this->is_theme_tracking || $this->advanced_code) {
         $output .= "</script>\n\r";
     }
     return $output;
 }
开发者ID:dreamteam111,项目名称:dreamteam,代码行数:43,代码来源:google-analytics.class.php

示例6: wpsc_user_purchases


//.........这里部分代码省略.........
                echo " <td class='details_total'>";
                $endtotal += $price;
                echo wpsc_currency_display($shipping + $price, array('display_as_html' => false));
                echo " </td>";
                echo '</tr>';
            }
            echo "<tr>";
            echo " <td>";
            echo " </td>";
            echo " <td>";
            echo " </td>";
            echo " <td>";
            echo " <td>";
            echo " </td>";
            echo " </td>";
            echo " <td class='details_totals_labels'>";
            echo "<strong>" . __('Total Shipping', 'wpsc') . ":</strong><br />";
            echo "<strong>" . __('Total Tax', 'wpsc') . ":</strong><br />";
            echo "<strong>" . __('Final Total', 'wpsc') . ":</strong>";
            echo " </td>";
            echo " <td class='details_totals_labels'>";
            $total_shipping += $purchase['base_shipping'];
            $endtotal += $total_shipping;
            $endtotal += $purchase['wpec_taxes_total'];
            echo wpsc_currency_display($total_shipping, array('display_as_html' => false)) . "<br />";
            if ($gsttotal) {
                //if false then must be exclusive.. doesnt seem too reliable needs more testing
                echo wpsc_currency_display($gsttotal, array('display_as_html' => false)) . "<br />";
            } else {
                echo wpsc_currency_display($purchase['wpec_taxes_total'], array('display_as_html' => false)) . "<br />";
            }
            echo wpsc_currency_display($endtotal, array('display_as_html' => false));
            echo " </td>";
            echo '</tr>';
            echo "</table>";
            echo "<br />";
            echo "<strong>" . __('Customer Details', 'wpsc') . ":</strong>";
            echo "<table class='customer_details'>";
            $usersql = $wpdb->prepare("SELECT `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "`.value, `" . WPSC_TABLE_CHECKOUT_FORMS . "`.* FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` LEFT JOIN `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` ON `" . WPSC_TABLE_CHECKOUT_FORMS . "`.id = `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "`.`form_id` WHERE `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "`.log_id = %d OR `" . WPSC_TABLE_CHECKOUT_FORMS . "`.type = 'heading' ORDER BY `" . WPSC_TABLE_CHECKOUT_FORMS . "`.`checkout_set`, `" . WPSC_TABLE_CHECKOUT_FORMS . "`.`checkout_order`", $purchase['id']);
            $formfields = $wpdb->get_results($usersql, ARRAY_A);
            if (!empty($formfields)) {
                foreach ((array) $formfields as $form_field) {
                    // If its a heading display the Name otherwise continue on
                    if ('heading' == $form_field['type']) {
                        echo "  <tr><td colspan='2'>" . esc_html($form_field['name']) . ":</td></tr>";
                        continue;
                    }
                    switch ($form_field['unique_name']) {
                        case 'shippingcountry':
                        case 'billingcountry':
                            $country = maybe_unserialize($form_field['value']);
                            if (is_array($country)) {
                                $country = $country[0];
                            } else {
                                $country = $form_field['value'];
                            }
                            echo "  <tr><td>" . esc_html($form_field['name']) . ":</td><td>" . esc_html($country) . "</td></tr>";
                            break;
                        case 'billingstate':
                        case 'shippingstate':
                            if (is_numeric($form_field['value'])) {
                                $state = wpsc_get_state_by_id($form_field['value'], 'name');
                            } else {
                                $state = $form_field['value'];
                            }
                            echo "  <tr><td>" . esc_html($form_field['name']) . ":</td><td>" . esc_html($state) . "</td></tr>";
                            break;
                        default:
                            echo "  <tr><td>" . esc_html($form_field['name']) . ":</td><td>" . esc_html($form_field['value']) . "</td></tr>";
                    }
                }
            }
            $payment_gateway_names = '';
            $payment_gateway_names = get_option('payment_gateway_names');
            foreach ((array) $payment_gateway_names as $gatewayname) {
                //if the gateway has a custom name
                if (!empty($gatewayname)) {
                    $display_name = $payment_gateway_names[$purchase_log[0]['gateway']];
                } else {
                    //if not fall back on default name
                    foreach ((array) $nzshpcrt_gateways as $gateway) {
                        if ($gateway['internalname'] == $purchase['gateway']) {
                            $display_name = $gateway['name'];
                        }
                    }
                }
            }
            echo "  <tr><td>" . __('Payment Method', 'wpsc') . ":</td><td>" . $display_name . "</td></tr>";
            echo "  <tr><td>" . __('Purchase #', 'wpsc') . ":</td><td>" . $purchase['id'] . "</td></tr>";
            if ($purchase['transactid'] != '') {
                echo "  <tr><td>" . __('Transaction Id', 'wpsc') . ":</td><td>" . $purchase['transactid'] . "</td></tr>";
            }
            echo "</table>";
        }
        echo "  </div>\n\r";
        echo "  </div>\n\r";
        echo " </td>\n\r";
        echo "</tr>\n\r";
    }
}
开发者ID:dreamteam111,项目名称:dreamteam,代码行数:101,代码来源:wpsc-user_log_functions.php

示例7: gateway_sagepay

 function gateway_sagepay($seperator, $sessionid)
 {
     global $wpdb;
     // Get Purchase Log
     $purchase_log_sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $sessionid . " LIMIT 1";
     $purchase_log = $wpdb->get_results($purchase_log_sql, ARRAY_A);
     // Get Cart Contents
     $cart_sql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`='" . $purchase_log[0]['id'] . "'";
     $cart = $wpdb->get_results($cart_sql, ARRAY_A);
     // exit('<pre>' . print_r($cart, true) . '</pre>');
     foreach ((array) $cart as $item) {
         $product_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id`='" . $item['prodid'] . "' LIMIT 1", ARRAY_A);
         $product_data = $product_data[0];
     }
     //Set Post Data
     $data['VendorTxCode'] = $sessionid;
     $data['Amount'] = number_format($purchase_log[0]['totalprice'], 2, '.', '');
     $data['Currency'] = get_option('protx_cur');
     $data['Description'] = get_bloginfo('name') . " wpEcommerce";
     $transact_url = get_option('transact_url');
     $site_url = get_option('shopping_cart_url');
     $data['SuccessURL'] = $transact_url . $seperator . "protx=success";
     $data['FailureURL'] = $site_url;
     // $data['FailureURL'] = urlencode($transact_url);
     if ($_POST['collected_data'][get_option('protx_form_last_name')] != '') {
         $data['BillingSurname'] = urlencode($_POST['collected_data'][get_option('protx_form_last_name')]);
     }
     if ($_POST['collected_data'][get_option('protx_form_post_code')] != '') {
         $data['BillingPostCode'] = $_POST['collected_data'][get_option('protx_form_post_code')];
     }
     if ($_POST['collected_data'][get_option('protx_form_address')] != '') {
         $data['BillingAddress1'] = $_POST['collected_data'][get_option('protx_form_address')];
     }
     if ($_POST['collected_data'][get_option('protx_form_city')] != '') {
         $data['BillingCity'] = $_POST['collected_data'][get_option('protx_form_city')];
     }
     if ($_POST['collected_data'][get_option('protx_form_first_name')] != '') {
         $data['BillingFirstnames'] = urlencode($_POST['collected_data'][get_option('protx_form_first_name')]);
     }
     if ($_POST['collected_data'][get_option('protx_form_country')] != '') {
         $result = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE isocode='" . $_POST['collected_data'][get_option('protx_form_country')][0] . "'", ARRAY_A);
         if ($result[0]['isocode'] == 'UK') {
             $data['BillingCountry'] = 'GB';
         } else {
             $data['BillingCountry'] = $result[0]['isocode'];
         }
     }
     //billingstate
     if (is_numeric($_POST['collected_data'][get_option('protx_form_country')][1])) {
         $data['BillingState'] = wpsc_get_state_by_id($_POST['collected_data'][get_option('protx_form_country')][1], 'code');
     }
     if ($_POST['collected_data'][get_option('protx_form_last_name')] != '') {
         $data['DeliverySurname'] = urlencode($_POST['collected_data'][get_option('protx_form_last_name')]);
     }
     if ($_POST['collected_data'][get_option('protx_form_post_code')] != '') {
         $data['DeliveryPostCode'] = $_POST['collected_data'][get_option('protx_form_post_code')];
     }
     if ($_POST['collected_data'][get_option('protx_form_address')] != '') {
         $data['DeliveryAddress1'] = $_POST['collected_data'][get_option('protx_form_address')];
     }
     if ($_POST['collected_data'][get_option('protx_form_city')] != '') {
         $data['DeliveryCity'] = $_POST['collected_data'][get_option('protx_form_city')];
     }
     if ($_POST['collected_data'][get_option('protx_form_first_name')] != '') {
         $data['DeliveryFirstnames'] = urlencode($_POST['collected_data'][get_option('protx_form_first_name')]);
     }
     if (preg_match("/^[a-zA-Z]{2}\$/", $_SESSION['wpsc_delivery_country'])) {
         $result = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE isocode='" . $_SESSION['wpsc_delivery_country'] . "'", ARRAY_A);
         if ($result[0]['isocode'] == 'UK') {
             $data['DeliveryCountry'] = 'GB';
         } else {
             $data['DeliveryCountry'] = $result[0]['isocode'];
         }
     }
     if ($data['DeliveryCountry'] == '') {
         $data['DeliveryCountry'] = 'GB';
     }
     //billingstate
     if (is_numeric($_SESSION['wpsc_delivery_region'])) {
         $data['DeliveryState'] = wpsc_get_state_by_id($_SESSION['wpsc_delivery_region'], 'code');
     }
     // Start Create Basket Data
     $basket_productprice_total = 0;
     $basket_rows = count($cart) + 1;
     if (!empty($purchase_log[0]['discount_value'])) {
         $basket_rows += 1;
     }
     $data['Basket'] = $basket_rows . ':';
     foreach ((array) $cart as $item) {
         $product_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id`='" . $item['prodid'] . "' LIMIT 1", ARRAY_A);
         $product_data = $product_data[0];
         $basket_productprice_total += $item['price'] * $item['quantity'];
         $data['Basket'] .= preg_replace('/[^a-z0-9]/i', '_', $product_data['name']) . ":" . $item['quantity'] . ":" . $item['price'] . ":---:" . $item['price'] * $item['quantity'] . ":" . $item['price'] * $item['quantity'] . ":";
     }
     $basket_delivery = $data['Amount'] - $basket_productprice_total;
     if (!empty($purchase_log[0]['discount_value'])) {
         $basket_delivery += $purchase_log[0]['discount_value'];
     }
     $data['Basket'] .= "Delivery:---:---:---:---:" . $basket_delivery;
     if (!empty($purchase_log[0]['discount_value'])) {
//.........这里部分代码省略.........
开发者ID:hornet9,项目名称:Morato,代码行数:101,代码来源:protx.php

示例8: wpsc_packing_slip

function wpsc_packing_slip($purchase_id)
{
    global $wpdb, $purchlogitem, $wpsc_cart, $purchlog;
    if (isset($_REQUEST['purchaselog_id'])) {
        $purchlogitem = new wpsc_purchaselogs_items((int) $_REQUEST['purchaselog_id']);
    }
    $purch_sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`='" . $purchase_id . "'";
    $purch_data = $wpdb->get_row($purch_sql, ARRAY_A);
    //echo "<p style='padding-left: 5px;'><strong>".__('Date', 'wpsc')."</strong>:".date("jS M Y", $purch_data['date'])."</p>";
    $cartsql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $purchase_id . "";
    $cart_log = $wpdb->get_results($cartsql, ARRAY_A);
    $j = 0;
    if ($cart_log != null) {
        echo "<div class='packing_slip'>\n\r";
        echo apply_filters('wpsc_packing_slip_header', '<h2>' . __('Packing Slip', 'wpsc') . "</h2>\n\r");
        echo "<strong>" . __('Order', 'wpsc') . " #</strong> " . $purchase_id . "<br /><br />\n\r";
        echo "<table>\n\r";
        /*
        		
        			$form_sql = "SELECT * FROM `".WPSC_TABLE_SUBMITED_FORM_DATA."` WHERE  `log_id` = '".(int)$purchase_id."'";
        			$input_data = $wpdb->get_results($form_sql,ARRAY_A);
        */
        echo "<tr class='heading'><td colspan='2'><strong>Billing Info</strong></td></tr>";
        foreach ((array) $purchlogitem->userinfo as $userinfo) {
            if ($userinfo['unique_name'] != 'billingcountry') {
                echo "<tr><td>" . $userinfo['name'] . ": </td><td>" . $userinfo['value'] . "</td></tr>";
            } else {
                $userinfo['value'] = maybe_unserialize($userinfo['value']);
                if (is_array($userinfo['value'])) {
                    if (!empty($userinfo['value'][1]) && !is_numeric($userinfo['value'][1])) {
                        echo "<tr><td>State: </td><td>" . $userinfo['value'][1] . "</td></tr>";
                    } elseif (is_numeric($userinfo['value'][1])) {
                        echo "<tr><td>State: </td><td>" . wpsc_get_state_by_id($userinfo['value'][1], 'name') . "</td></tr>";
                    }
                    if (!empty($userinfo['value'][0])) {
                        echo "<tr><td>Country: </td><td>" . $userinfo['value'][0] . "</td></tr>";
                    }
                } else {
                    echo "<tr><td>" . $userinfo['name'] . ": </td><td>" . $userinfo['value'] . "</td></tr>";
                }
            }
        }
        echo "<tr class='heading'><td colspan='2'><strong>Shipping Info</strong></td></tr>";
        foreach ((array) $purchlogitem->shippinginfo as $userinfo) {
            if ($userinfo['unique_name'] != 'shippingcountry' && $userinfo['unique_name'] != 'shippingstate') {
                echo "<tr><td>" . $userinfo['name'] . ": </td><td>" . $userinfo['value'] . "</td></tr>";
            } elseif ($userinfo['unique_name'] == 'shippingcountry') {
                $userinfo['value'] = maybe_unserialize($userinfo['value']);
                if (is_array($userinfo['value'])) {
                    if (!empty($userinfo['value'][1]) && !is_numeric($userinfo['value'][1])) {
                        echo "<tr><td>State: </td><td>" . $userinfo['value'][1] . "</td></tr>";
                    } elseif (is_numeric($userinfo['value'][1])) {
                        echo "<tr><td>State: </td><td>" . wpsc_get_state_by_id($userinfo['value'][1], 'name') . "</td></tr>";
                    }
                    if (!empty($userinfo['value'][0])) {
                        echo "<tr><td>Country: </td><td>" . $userinfo['value'][0] . "</td></tr>";
                    }
                } else {
                    echo "<tr><td>" . $userinfo['name'] . ": </td><td>" . $userinfo['value'] . "</td></tr>";
                }
            } elseif ($userinfo['unique_name'] == 'shippingstate') {
                if (!empty($userinfo['value']) && !is_numeric($userinfo['value'])) {
                    echo "<tr><td>" . $userinfo['name'] . ": </td><td>" . $userinfo['value'] . "</td</tr>>";
                } elseif (is_numeric($userinfo['value'])) {
                    echo "<tr><td>State: </td><td>" . wpsc_get_state_by_id($userinfo['value'], 'name') . "</td></tr>";
                }
            }
        }
        //		echo('<pre>'.print_r($purchlogitem,true).'</pre>');
        /*
        	foreach($input_data as $input_row) {
        			  $rekeyed_input[$input_row['form_id']] = $input_row;
        			}
        			
        			
        			if($input_data != null) {
                $form_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1'",ARRAY_A);
            // exit('<pre>'.print_r($purch_data, true).'</pre>');
                foreach($form_data as $form_field) {
                  switch($form_field['type']) {
        			case 'country':
        
        						$delivery_region_count = $wpdb->get_var("SELECT COUNT(`regions`.`id`) FROM `".WPSC_TABLE_REGION_TAX."` AS `regions` INNER JOIN `".WPSC_TABLE_CURRENCY_LIST."` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN('".$wpdb->escape( $purch_data['billing_country'])."')");
        
                    if(is_numeric($purch_data['billing_region']) && ($delivery_region_count > 0)) {
                      echo "  <tr><td>".__('State', 'wpsc').":</td><td>".wpsc_get_region($purch_data['billing_region'])."</td></tr>\n\r";
                    }
                    echo "  <tr><td>".wp_kses($form_field['name'], array() ).":</td><td>".wpsc_get_country($purch_data['billing_country'])."</td></tr>\n\r";
                    break;
                        
                    case 'delivery_country':
                    echo "  <tr><td>".$form_field['name'].":</td><td>".wpsc_get_country($purch_data['shipping_country'])."</td></tr>\n\r";
                    break;
                        
                    case 'heading':
                    echo "  <tr><td colspan='2'><strong>".wp_kses($form_field['name'], array()).":</strong></td></tr>\n\r";
                    break;
                    
                    default:
                    if($form_field['unique_name'] == 'shippingstate'){
//.........这里部分代码省略.........
开发者ID:kasima,项目名称:wp-e-commerce-ezp,代码行数:101,代码来源:admin-form-functions.php

示例9: transaction_results


//.........这里部分代码省略.........
	', 'wpsc'), wpsc_currency_display($total_shipping));
            }
            $total_price_html .= sprintf(__('Total: %s
', 'wpsc'), wpsc_currency_display($total));
            $report_id = sprintf(__("Purchase # %s\n", 'wpsc'), $purchase_log['id']);
            if (isset($_GET['ti'])) {
                $message .= "\n\r" . __('Your Transaction ID', 'wpsc') . ": " . $_GET['ti'];
                $message_html .= "\n\r" . __('Your Transaction ID', 'wpsc') . ": " . $_GET['ti'];
                $report .= "\n\r" . __('Transaction ID', 'wpsc') . ": " . $_GET['ti'];
            }
            $message = apply_filters('wpsc_transaction_result_message', $message);
            $message = str_replace('%purchase_id%', $report_id, $message);
            $message = str_replace('%product_list%', $product_list, $message);
            $message = str_replace('%total_tax%', $total_tax, $message);
            $message = str_replace('%total_shipping%', $total_shipping_email, $message);
            $message = str_replace('%total_price%', $total_price_email, $message);
            $message = str_replace('%shop_name%', get_option('blogname'), $message);
            $message = str_replace('%find_us%', $purchase_log['find_us'], $message);
            $report = apply_filters('wpsc_transaction_result_report', $report);
            $report = str_replace('%purchase_id%', $report_id, $report);
            $report = str_replace('%product_list%', $report_product_list, $report);
            $report = str_replace('%total_tax%', $total_tax, $report);
            $report = str_replace('%total_shipping%', $total_shipping_email, $report);
            $report = str_replace('%total_price%', $total_price_email, $report);
            $report = str_replace('%shop_name%', get_option('blogname'), $report);
            $report = str_replace('%find_us%', $purchase_log['find_us'], $report);
            $message_html = apply_filters('wpsc_transaction_result_message_html', $message_html);
            $message_html = str_replace('%purchase_id%', $report_id, $message_html);
            $message_html = str_replace('%product_list%', $product_list_html, $message_html);
            $message_html = str_replace('%total_tax%', $total_tax_html, $message_html);
            $message_html = str_replace('%total_shipping%', $total_shipping_html, $message_html);
            $message_html = str_replace('%total_price%', $total_price_html, $message_html);
            $message_html = str_replace('%shop_name%', get_option('blogname'), $message_html);
            $message_html = str_replace('%find_us%', $purchase_log['find_us'], $message_html);
            if (!empty($email)) {
                add_filter('wp_mail_from', 'wpsc_replace_reply_address', 0);
                add_filter('wp_mail_from_name', 'wpsc_replace_reply_name', 0);
                $message = apply_filters('wpsc_email_message', $message, $report_id, $product_list, $total_tax, $total_shipping_email, $total_price_email);
                if (!$is_transaction) {
                    $payment_instructions = strip_tags(stripslashes(get_option('payment_instructions')));
                    if (!empty($payment_instructions)) {
                        $payment_instructions .= "\n\r";
                    }
                    $message = __('Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc') . "\n\r" . $payment_instructions . $message;
                    $message_html = __('Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc') . "\n\r" . $payment_instructions . $message_html;
                    // prevent email duplicates
                    if (!get_transient("{$sessionid}_pending_email_sent") || $resend_email) {
                        wp_mail($email, __('Order Pending: Payment Required', 'wpsc'), $message);
                        set_transient("{$sessionid}_pending_email_sent", true, 60 * 60 * 12);
                    }
                } elseif (!get_transient("{$sessionid}_receipt_email_sent") || $resend_email) {
                    wp_mail($email, __('Purchase Receipt', 'wpsc'), $message);
                    set_transient("{$sessionid}_receipt_email_sent", true, 60 * 60 * 12);
                }
            }
            remove_filter('wp_mail_from_name', 'wpsc_replace_reply_name');
            remove_filter('wp_mail_from', 'wpsc_replace_reply_address');
            $report_user = __('Customer Details', 'wpsc') . "\n\r";
            $form_sql = $wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` = %d", $purchase_log['id']);
            $form_data = $wpdb->get_results($form_sql, ARRAY_A);
            if ($form_data != null) {
                foreach ($form_data as $form_field) {
                    $form_data = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `id` = %d LIMIT 1", $form_field['form_id']), ARRAY_A);
                    switch ($form_data['type']) {
                        case "country":
                            $country_code = $form_field['value'];
                            $report_user .= $form_data['name'] . ": " . wpsc_get_country($country_code) . "\n";
                            //check if country has a state then display if it does.
                            $country_data = wpsc_country_has_state($country_code);
                            if ($country_data['has_regions'] == 1) {
                                $report_user .= __('Billing State', 'wpsc') . ": " . wpsc_get_region($purchase_log['billing_region']) . "\n";
                            }
                            break;
                        case "delivery_country":
                            $report_user .= $form_data['name'] . ": " . wpsc_get_country($form_field['value']) . "\n";
                            break;
                        default:
                            if ($form_data['name'] == 'State' && is_numeric($form_field['value'])) {
                                $report_user .= __('Delivery State', 'wpsc') . ": " . wpsc_get_state_by_id($form_field['value'], 'name') . "\n";
                            } else {
                                $report_user .= wp_kses($form_data['name'], array()) . ": " . $form_field['value'] . "\n";
                            }
                            break;
                    }
                }
            }
            $report_user .= "\n\r";
            $report = $report_id . $report_user . $report;
            //echo '======REPORT======<br />'.$report.'<br />';
            //echo '======EMAIL======<br />'.$message.'<br />';
            if (get_option('purch_log_email') != null && $purchase_log['email_sent'] != 1) {
                wp_mail(get_option('purch_log_email'), __('Purchase Report', 'wpsc'), $report);
                $wpdb->update(WPSC_TABLE_PURCHASE_LOGS, array('email_sent' => '1'), array('sessionid' => $sessionid));
            }
            /// Adjust stock and empty the cart
            $wpsc_cart->submit_stock_claims($purchase_log['id']);
            $wpsc_cart->empty_cart();
        }
    }
}
开发者ID:arturo-mayorga,项目名称:am_com,代码行数:101,代码来源:wpsc-transaction_results_functions.php

示例10: gateway_bluepay

function gateway_bluepay($seperator, $sessionid)
{
    //$transact_url = get_option('transact_url');
    //exit("<pre>".print_r($_POST,true)."</pre>");
    //   if($_SESSION['cart_paid'] == true)
    //     {
    //     header("Location: ".get_option('transact_url').$seperator."sessionid=".$sessionid);
    //     }
    $x_Login = urlencode(get_option('bluepay_login'));
    // Replace LOGIN with your login
    $x_Password = urlencode(get_option("bluepay_password"));
    // Replace PASS with your password
    $x_Delim_Data = urlencode("TRUE");
    $x_Delim_Char = urlencode(",");
    $x_Encap_Char = urlencode("");
    $x_Type = urlencode("AUTH_CAPTURE");
    $x_ADC_Relay_Response = urlencode("FALSE");
    if (get_option('bluepay_testmode') == 1) {
        $x_Test_Request = urlencode("TRUE");
        // Remove this line of code when you are ready to go live
    }
    #
    # Customer Information
    #
    $x_Method = urlencode("CC");
    $x_Amount = urlencode(nzshpcrt_overall_total_price($_SESSION['delivery_country']));
    //exit($x_Amount);
    $x_First_Name = urlencode($_POST['collected_data'][get_option('bluepay_form_first_name')]);
    $x_Last_Name = urlencode($_POST['collected_data'][get_option('bluepay_form_last_name')]);
    $x_Card_Num = urlencode($_POST['card_number']);
    $ExpDate = urlencode($_POST['expiry']['month'] . $_POST['expiry']['year']);
    $x_Exp_Date = $ExpDate;
    $x_Address = urlencode($_POST['collected_data'][get_option('bluepay_form_address')]);
    $x_City = urlencode($_POST['collected_data'][get_option('bluepay_form_city')]);
    $State = urlencode($_POST['collected_data'][get_option('bluepay_form_state')]);
    $x_State = wpsc_get_state_by_id($State, 'name');
    $x_Zip = urlencode($_POST['collected_data'][get_option('bluepay_form_post_code')]);
    $x_Email = urlencode($_POST['collected_data'][get_option('bluepay_form_email')]);
    $x_Email_Customer = urlencode("TRUE");
    $x_Merchant_Email = urlencode(get_option('purch_log_email'));
    //  Replace MERCHANT_EMAIL with the merchant email address
    $x_Card_Code = urlencode($_POST['card_code']);
    #
    # Build fields string to post
    #
    $fields = "x_Version=3.1&x_Login={$x_Login}&x_Delim_Data={$x_Delim_Data}&x_Delim_Char={$x_Delim_Char}&x_Encap_Char={$x_Encap_Char}";
    $fields .= "&x_Type={$x_Type}&x_Test_Request={$x_Test_Request}&x_Method={$x_Method}&x_Amount={$x_Amount}&x_First_Name={$x_First_Name}";
    $fields .= "&x_Last_Name={$x_Last_Name}&x_Card_Num={$x_Card_Num}&x_Exp_Date={$x_Exp_Date}&x_Card_Code={$x_Card_Code}&x_Address={$x_Address}&x_City={$x_City}&x_State={$x_State}&x_Zip={$x_Zip}&x_Email={$x_Email}&x_Email_Customer={$x_Email_Customer}&x_Merchant_Email={$x_Merchant_Email}&x_ADC_Relay_Response={$x_ADC_Relay_Response}";
    if ($x_Password != '') {
        $fields .= "&x_Password={$x_Password}";
    }
    //exit($fields);
    #
    # Start CURL session
    #
    $agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)";
    $ref = get_option('transact_url');
    // Replace this URL with the URL of this script
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://secure.bluepay.com/interfaces/a.net");
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_NOPROGRESS, 1);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
    curl_setopt($ch, CURLOPT_TIMEOUT, 120);
    curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    curl_setopt($ch, CURLOPT_REFERER, $ref);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $buffer = curl_exec($ch);
    curl_close($ch);
    // This section of the code is the change from Version 1.
    // This allows this script to process all information provided by Authorize.net...
    // and not just whether if the transaction was successful or not
    // Provided in the true spirit of giving by Chuck Carpenter (Chuck@MLSphotos.com)
    // Be sure to email him and tell him how much you appreciate his efforts for PHP coders everywhere
    $return = preg_split("/[,]+/", "{$buffer}");
    // Splits out the buffer return into an array so . . .
    $details = $return[0];
    // This can grab the Transaction ID at position 1 in the array
    // echo "Location: ".$transact_url.$seperator."sessionid=".$sessionid;
    // exit("<pre>".print_r($return,true)."</pre>");
    // Change the number to grab additional information.  Consult the AIM guidelines to see what information is provided in each position.
    // For instance, to get the Transaction ID from the returned information (in position 7)..
    // Simply add the following:
    // $x_trans_id = $return[6];
    // You may then use the switch statement (or other process) to process the information provided
    // Example below is to see if the transaction was charged successfully
    if (get_option('permalink_structure') != '') {
        $seperator = "?";
    } else {
        $seperator = "&";
    }
    //exit("<pre>".print_r($return,true)."</pre>");
    switch ($details) {
        case 1:
            // Credit Card Successfully Charged
            //$_SESSION['cart_paid'] = true;
            header("Location: " . get_option('transact_url') . $seperator . "sessionid=" . $sessionid);
//.........这里部分代码省略.........
开发者ID:hornet9,项目名称:Morato,代码行数:101,代码来源:bluepay.php

示例11: _wpsc_updated_visitor_meta_billingregion

/**
 * Update any values dependant on billing region
 *
 * @since 3.8.14
 *
 * @access private
 * @param mixed $meta_value Optional. Metadata value.
 * @param string $meta_key Metadata name.
 * @param int $visitor_id visitor ID
 * @return none
 */
function _wpsc_updated_visitor_meta_billingregion($meta_value, $meta_key, $visitor_id)
{
    if (!empty($meta_value)) {
        $billingstate = wpsc_get_state_by_id($meta_value, 'name');
    } else {
        $billingstate = '';
    }
    wpsc_update_visitor_meta($visitor_id, 'billingstate', $billingstate);
}
开发者ID:VanessaGarcia-Freelance,项目名称:ButtonHut,代码行数:20,代码来源:wpsc-meta-visitor.php

示例12: gateway_bitpay

function gateway_bitpay($seperator, $sessionid)
{
    global $wpdb;
    global $wpsc_cart;
    try {
        // Protect your data!
        $mcrypt_ext = new \Bitpay\Crypto\McryptExtension();
        $fingerprint = substr(sha1(sha1(__DIR__)), 0, 24);
        //Use token that is in_use and with facade = pos for generating invoices
        $is_a_token_paired = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "bitpay_keys WHERE `in_use` = 'true' AND `facade` = 'pos' LIMIT 1");
        if ($is_a_token_paired < 1) {
            debuglog('[Error] In Bitpay plugin, bitpay.merchant.php::gateway_bitpay(): No tokens are paired so no transactions can be done!');
            var_dump("Error Processing Transaction. Please try again later. If the problem persists, please contact us at " . get_option('admin_email'));
        }
        $row = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "bitpay_keys WHERE `in_use` = 'true' AND `facade` = 'pos' LIMIT 1");
        $token = unserialize(base64_decode($mcrypt_ext->decrypt($row[0]->token, $fingerprint, '00000000')));
        $public_key = unserialize(base64_decode($mcrypt_ext->decrypt($row[0]->public_key, $fingerprint, '00000000')));
        $private_key = unserialize(base64_decode($mcrypt_ext->decrypt($row[0]->private_key, $fingerprint, '00000000')));
        $network = $row[0]->network === 'Livenet' ? new \Bitpay\Network\Livenet() : new \Bitpay\Network\Testnet();
        $row_id = $row[0]->id;
        $adapter = new \Bitpay\Client\Adapter\CurlAdapter();
        // This grabs the purchase log id from
        // the database that refers to the $sessionid
        $purchase_log = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $sessionid . " LIMIT 1", ARRAY_A);
        // This grabs the users info using the
        // $purchase_log from the previous SQL query
        $usersql = "SELECT  `" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.value," . "`" . WPSC_TABLE_CHECKOUT_FORMS . "`.`name`," . "`" . WPSC_TABLE_CHECKOUT_FORMS . "`.`unique_name` FROM " . "`" . WPSC_TABLE_CHECKOUT_FORMS . "` LEFT JOIN " . "`" . WPSC_TABLE_SUBMITED_FORM_DATA . "` ON " . "`" . WPSC_TABLE_CHECKOUT_FORMS . "`.id = " . "`" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.`form_id` WHERE " . "`" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.`log_id`='" . $purchase_log['id'] . "'";
        $userinfo = $wpdb->get_results($usersql, ARRAY_A);
        // convert from awkward format
        $ui = array();
        foreach ((array) $userinfo as $value) {
            if (strlen($value['value'])) {
                $ui[$value['unique_name']] = $value['value'];
            }
        }
        $userinfo = $ui;
        /**
         * Create Buyer object that will be used later.
         */
        $buyer = new \Bitpay\Buyer();
        // name
        if (true === isset($userinfo['billingfirstname'])) {
            $buyer->setFirstName($userinfo['billingfirstname']);
        }
        if (true === isset($userinfo['billinglastname'])) {
            $buyer->setLastName($userinfo['billinglastname']);
        }
        // address -- remove newlines
        if (true === isset($userinfo['billingaddress'])) {
            $newline = strpos($userinfo['billingaddress'], "\n");
            $address2 = '';
            if ($newline !== FALSE) {
                $address_line1 = substr($userinfo['billingaddress'], 0, $newline);
                $address_line2 = substr($userinfo['billingaddress'], $newline + 1);
                $address_line2 = preg_replace('/\\r\\n/', ' ', $address_line2, -1, $count);
            } else {
                $address_line1 = $userinfo['billingaddress'];
            }
            $buyer->setAddress(array($address_line1, $address_line2));
        }
        // state
        if (true === isset($userinfo['billingstate'])) {
            // check if State is a number code used when Selecting country as US
            if (true === ctype_digit($userinfo['billingstate'])) {
                $buyer->setState(wpsc_get_state_by_id($userinfo['billingstate'], 'code'));
            } else {
                $buyer->setState($userinfo['billingstate']);
            }
        }
        // country
        if (true === isset($userinfo['billingcountry'])) {
            $buyer->setCountry($userinfo['billingcountry']);
        }
        // city
        if (true === isset($userinfo['billingcity'])) {
            $buyer->setCity($userinfo['billingcity']);
        }
        // postal code
        if (true === isset($userinfo['billingpostcode'])) {
            $buyer->setZip($userinfo['billingpostcode']);
        }
        // email
        if (true === isset($userinfo['billingemail'])) {
            $buyer->setEmail($userinfo['billingemail']);
        }
        // phone
        if (true === isset($userinfo['billingphone'])) {
            $buyer->setPhone($userinfo['billingphone']);
        }
        // more user info
        foreach (array('billingphone' => 'buyerPhone', 'billingemail' => 'buyerEmail', 'billingcity' => 'buyerCity', 'billingcountry' => 'buyerCountry', 'billingpostcode' => 'buyerZip') as $f => $t) {
            if ($userinfo[$f]) {
                $options[$t] = $userinfo[$f];
            }
        }
        /**
         * Create an Item object that will be used later
         */
        $item = new \Bitpay\Item();
        // itemDesc, Sku, and Quantity
//.........这里部分代码省略.........
开发者ID:cryptocurrent,项目名称:wordpress-ecommerce-plugin,代码行数:101,代码来源:bitpay.merchant.php

示例13: add_pushes

 public function add_pushes($session_id)
 {
     $purchase = new WPSC_Purchase_Log($session_id, 'sessionid');
     $purchase_id = $purchase->get('id');
     $data = new WPSC_Checkout_Form_Data($purchase_id);
     $output = '';
     $city = $data->get('billingcity');
     $state = $data->get('billingstate');
     $country = $data->get('billingcountry');
     $state = !empty($state) ? wpsc_get_state_by_id($state, 'name') : '';
     $cart_items = $purchase->get_cart_contents();
     $total_shipping = wpsc_get_total_shipping($purchase_id);
     $total_tax = $total_price = 0;
     foreach ($cart_items as $item) {
         /* For backwards compatibility, convert objects to arrays */
         $item = (array) $item;
         $total_tax += $item['tax_charged'];
         $total_price += absint($item['quantity']) * $item['price'];
     }
     if ($this->is_theme_tracking || $this->advanced_code) {
         $output .= "<script type='text/javascript'>\n\r";
     }
     add_filter('wpsc_toggle_display_currency_code', array($this, 'remove_currency_and_html'));
     if ($this->use_universal_analytics()) {
         // Yoast GA Plugin switched to it's own object name __gaTracker - assign it to our ga object if it exists
         $output .= "var ga = typeof ga === 'undefined' && typeof __gaTracker !== 'undefined' ? __gaTracker : ga;";
         $output .= "ga('require', 'ecommerce');\n\r";
         $output .= "ga('ecommerce:addTransaction', {\n\t\t\t\t'id': '" . $purchase_id . "',                                               // Transaction ID. Required.\n\t\t\t\t'affiliation': '" . wp_specialchars_decode($this->get_site_name()) . "',  // Affiliation or store name.\n\t\t\t\t'revenue': '" . number_format($total_price, 2, '.', '') . "',             // Grand Total.\n\t\t\t\t'shipping': '" . wpsc_currency_display($total_shipping) . "',             // Shipping.\n\t\t\t\t'tax': '" . wpsc_currency_display($total_tax) . "'                        // Tax.\n\t\t\t});\n\r";
     } else {
         $output .= "\n\t\t\t\t_gaq.push(['_addTrans',\n\t\t\t\t'" . $purchase_id . "',                                     // order ID - required\n\t\t\t\t'" . wp_specialchars_decode($this->get_site_name()) . "', // affiliation or store name\n\t\t\t\t'" . number_format($total_price, 2, '.', '') . "',   // total - required\n\t\t\t\t'" . wpsc_currency_display($total_tax) . "',              // tax\n\t\t\t\t'" . wpsc_currency_display($total_shipping) . "',         // shipping\n\t\t\t\t'" . wp_specialchars_decode($city) . "',                  // city\n\t\t\t\t'" . wp_specialchars_decode($state) . "',                 // state or province\n\t\t\t\t'" . wp_specialchars_decode($country) . "'                // country\n\t\t\t]);\n\r";
     }
     remove_filter('wpsc_toggle_display_currency_code', array($this, 'remove_currency_and_html'));
     foreach ($cart_items as $item) {
         /* For backwards compatibility, convert objects to arrays */
         $item = (array) $item;
         $category = wp_get_object_terms($item['prodid'], 'wpsc_product_category', array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'all_with_object_id'));
         $item['sku'] = get_post_meta($item['prodid'], '_wpsc_sku', true);
         if (empty($item['sku'])) {
             $item['sku'] = $item['prodid'];
         }
         if ($category) {
             $item['category'] = $category[0]->name;
         } else {
             $item['category'] = '';
         }
         $item = apply_filters('wpsc_google_analytics_pushed_product', array_map('wp_specialchars_decode', $item), $item, $this);
         if ($this->use_universal_analytics()) {
             $output .= "ga('ecommerce:addItem', {" . "'id': '" . $purchase_id . "'," . "'name': '" . $item['name'] . "'," . "'sku': '" . $item['sku'] . "'," . "'category': '" . $item['category'] . "'," . "'price': '" . $item['price'] . "'," . "'quantity': '" . $item['quantity'] . "'" . "});\n\r";
         } else {
             $output .= "_gaq.push(['_addItem'," . "'" . $purchase_id . "'," . "'" . $item['sku'] . "'," . "'" . $item['name'] . "'," . "'" . $item['category'] . "'," . "'" . $item['price'] . "'," . "'" . $item['quantity'] . "']);\n\r";
             // Item Quantity
         }
     }
     if ($this->use_universal_analytics()) {
         $output .= "ga('ecommerce:send');\n\r";
     } else {
         $output .= "_gaq.push(['_trackTrans']);\n\r";
     }
     if ($this->is_theme_tracking || $this->advanced_code) {
         $output .= "</script>\n\r";
     }
     return $output;
 }
开发者ID:ashik968,项目名称:digiplot,代码行数:63,代码来源:google-analytics.class.php

示例14: Usecase

function Usecase($separator, $sessionid, $fromcheckout)
{
    global $wpdb, $wpsc_cart;
    $purchase_log_sql = $wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` = %s  LIMIT 1", $sessionid);
    $purchase_log = $wpdb->get_results($purchase_log_sql, ARRAY_A);
    $cart_sql = $wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` = %d", $purchase_log[0]['id']);
    $wp_cart = $wpdb->get_results($cart_sql, ARRAY_A);
    $merchant_id = get_option('google_id');
    $merchant_key = get_option('google_key');
    $server_type = get_option('google_server_type');
    $currency = get_option('google_cur');
    $transact_url = get_option('transact_url');
    $returnURL = $transact_url . $separator . "sessionid=" . $sessionid . "&gateway=google";
    $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency);
    $cart->SetContinueShoppingUrl($returnURL);
    $cart->SetEditCartUrl(get_option('shopping_cart_url'));
    //google prohibited items not implemented
    $currency_converter = new CURRENCYCONVERTER();
    $currency_code = $wpdb->get_results("SELECT `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`='" . get_option('currency_type') . "' LIMIT 1", ARRAY_A);
    $local_currency_code = $currency_code[0]['code'];
    $google_curr = get_option('google_cur');
    $currentcy_rate = 1;
    if ($google_curr != $local_currency_code) {
        $currentcy_rate = $currency_converter->convert(1, $local_currency_code, $google_curr);
    }
    while (wpsc_have_cart_items()) {
        wpsc_the_cart_item();
        $google_currency_productprice = $currentcy_rate * (wpsc_cart_item_price(false) / wpsc_cart_item_quantity());
        $cart_item = new GoogleItem(wpsc_cart_item_name(), '', wpsc_cart_item_quantity(), $google_currency_productprice);
        $cart->AddItem($cart_item);
    }
    //If there are coupons applied add coupon as a product with negative price
    if ($wpsc_cart->coupons_amount > 0) {
        $google_currency_productprice = $currentcy_rate * $wpsc_cart->coupons_amount;
        $coupon = new GoogleItem('Discount', 'Discount Price', 1, '-' . $google_currency_productprice);
        $cart->AddItem($coupon);
    }
    $shipping_country = $purchase_log[0]['shipping_country'];
    $shipping_region = $purchase_log[0]['shipping_region'];
    if ($shipping_country == "UK") {
        $shipping_country = "GB";
    }
    // Add shipping options
    if (wpsc_uses_shipping()) {
        $shipping_name = ucfirst($wpsc_cart->selected_shipping_method) . " - " . $wpsc_cart->selected_shipping_option;
        if ($shipping_name == "") {
            $shipping_name = "Calculated";
        }
        $shipping = new GoogleFlatRateShipping($shipping_name, $wpsc_cart->calculate_total_shipping() * $currentcy_rate);
        if (!empty($shipping_country)) {
            $shipping_filter = new GoogleShippingFilters();
            if (!empty($shipping_region) && is_numeric($shipping_region)) {
                $shipping_filter->AddAllowedPostalArea($shipping_country, wpsc_get_state_by_id($shipping_region, "code"));
                $shipping_filter->AddAllowedStateArea(wpsc_get_state_by_id($shipping_region, "code"));
            } else {
                $shipping_filter->AddAllowedPostalArea($shipping_country);
            }
            $shipping->AddShippingRestrictions($shipping_filter);
        }
        $cart->AddShipping($shipping);
    }
    // Add tax rules
    if (!empty($shipping_country)) {
        $tax_rule = new GoogleDefaultTaxRule(wpsc_cart_tax(false) / $wpsc_cart->calculate_subtotal());
        $tax_rule->AddPostalArea($shipping_country);
        $cart->AddDefaultTaxRules($tax_rule);
    }
    // Display Google Checkout button
    if (get_option('google_button_size') == '0') {
        $google_button_size = 'BIG';
    } elseif (get_option('google_button_size') == '1') {
        $google_button_size = 'MEDIUM';
    } elseif (get_option('google_button_size') == '2') {
        $google_button_size = 'SMALL';
    }
    echo $cart->CheckoutButtonCode($google_button_size);
}
开发者ID:arturo-mayorga,项目名称:am_com,代码行数:77,代码来源:GoogleCheckout-XML.php

示例15: wpsc_purchase_log_csv

function wpsc_purchase_log_csv()
{
    global $wpdb, $wpsc_gateways;
    get_currentuserinfo();
    $count = 0;
    if ('key' == $_REQUEST['rss_key'] && current_user_can('manage_options')) {
        if (isset($_REQUEST['start_timestamp']) && isset($_REQUEST['end_timestamp'])) {
            $start_timestamp = $_REQUEST['start_timestamp'];
            $end_timestamp = $_REQUEST['end_timestamp'];
            $start_end_sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '%d' AND '%d' ORDER BY `date` DESC";
            $start_end_sql = apply_filters('wpsc_purchase_log_start_end_csv', $start_end_sql);
            $data = $wpdb->get_results($wpdb->prepare($start_end_sql, $start_timestamp, $end_timestamp), ARRAY_A);
            /* translators: %1$s is "start" date, %2$s is "to" date */
            $csv_name = _x('Purchase Log %1$s to %2$s.csv', 'exported purchase log csv file name', 'wpsc');
            $csv_name = sprintf($csv_name, date("M-d-Y", $start_timestamp), date("M-d-Y", $end_timestamp));
        } elseif (isset($_REQUEST['m'])) {
            $year = (int) substr($_REQUEST['m'], 0, 4);
            $month = (int) substr($_REQUEST['m'], -2);
            $month_year_sql = "\n\t\t\t\tSELECT *\n\t\t\t\tFROM " . WPSC_TABLE_PURCHASE_LOGS . "\n\t\t\t\tWHERE YEAR(FROM_UNIXTIME(date)) = %d AND MONTH(FROM_UNIXTIME(date)) = %d\n\t\t\t\tORDER BY `id` DESC\n\t\t\t";
            $month_year_sql = apply_filters('wpsc_purchase_log_month_year_csv', $month_year_sql);
            $data = $wpdb->get_results($wpdb->prepare($month_year_sql, $year, $month), ARRAY_A);
            /* translators: %1$s is month, %2$s is year */
            $csv_name = _x('Purchase Log %1$s/%2$s.csv', 'exported purchase log csv file name', 'wpsc');
            $csv_name = sprintf($csv_name, $month, $year);
        } else {
            $sql = apply_filters('wpsc_purchase_log_month_year_csv', "SELECT * FROM " . WPSC_TABLE_PURCHASE_LOGS . " ORDER BY `id` DESC");
            $data = $wpdb->get_results($sql, ARRAY_A);
            $csv_name = _x("All Purchase Logs.csv", 'exported purchase log csv file name', 'wpsc');
        }
        $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `type` != 'heading' ORDER BY `checkout_order` DESC;";
        $form_data = $wpdb->get_results($form_sql, ARRAY_A);
        $headers_array = array(_x('Purchase ID', 'purchase log csv headers', 'wpsc'), _x('Purchase Total', 'purchase log csv headers', 'wpsc'));
        $headers2_array = array(_x('Payment Gateway', 'purchase log csv headers', 'wpsc'), _x('Payment Status', 'purchase log csv headers', 'wpsc'), _x('Purchase Date', 'purchase log csv headers', 'wpsc'));
        $form_headers_array = array();
        $output = '';
        foreach ((array) $form_data as $form_field) {
            if (empty($form_field['unique_name'])) {
                $form_headers_array[] = $form_field['name'];
            } else {
                $prefix = false === strstr($form_field['unique_name'], 'billing') ? _x('Shipping ', 'purchase log csv header field prefix', 'wpsc') : _x('Billing ', 'purchase log csv header field prefix', 'wpsc');
                $form_headers_array[] = $prefix . $form_field['name'];
            }
        }
        foreach ((array) $data as $purchase) {
            $form_headers = '';
            $output .= "\"" . $purchase['id'] . "\",";
            //Purchase ID
            $output .= "\"" . $purchase['totalprice'] . "\",";
            //Purchase Total
            foreach ((array) $form_data as $form_field) {
                $collected_data_sql = "SELECT * FROM `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` WHERE `log_id` = '" . $purchase['id'] . "' AND `form_id` = '" . $form_field['id'] . "' LIMIT 1";
                $collected_data = $wpdb->get_results($collected_data_sql, ARRAY_A);
                $collected_data = $collected_data[0];
                if (('billingstate' == $form_field['unique_name'] || 'shippingstate' == $form_field['unique_name']) && is_numeric($collected_data['value'])) {
                    $output .= "\"" . wpsc_get_state_by_id($collected_data['value'], 'code') . "\",";
                } else {
                    $output .= "\"" . str_replace(array("\r", "\r\n", "\n"), ' ', $collected_data['value']) . "\",";
                }
                // get form fields
            }
            if (isset($wpsc_gateways[$purchase['gateway']]) && isset($wpsc_gateways[$purchase['gateway']]['display_name'])) {
                $output .= "\"" . $wpsc_gateways[$purchase['gateway']]['display_name'] . "\",";
            } else {
                $output .= "\"\",";
            }
            $status_name = wpsc_find_purchlog_status_name($purchase['processed']);
            $output .= "\"" . $status_name . "\",";
            //get purchase status
            $output .= "\"" . date("jS M Y", $purchase['date']) . "\",";
            //date
            $cartsql = "SELECT `prodid`, `quantity`, `name` FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $purchase['id'] . "";
            $cart = $wpdb->get_results($cartsql, ARRAY_A);
            if ($count < count($cart)) {
                $count = count($cart);
            }
            $items = count($cart);
            $i = 1;
            // Go through all products in cart and display quantity and sku
            foreach ((array) $cart as $item) {
                $skuvalue = get_product_meta($item['prodid'], 'sku', true);
                if (empty($skuvalue)) {
                    $skuvalue = __('N/A', 'wpsc');
                }
                $output .= "\"" . $item['quantity'] . "\",";
                $output .= "\"" . str_replace('"', '\\"', $item['name']) . "\",";
                if ($items <= 1) {
                    $output .= "\"" . $skuvalue . "\"";
                } elseif ($items > 1 && $i != $items) {
                    $output .= "\"" . $skuvalue . "\",";
                } else {
                    $output .= "\"" . $skuvalue . "\"";
                }
                $i++;
            }
            $output .= "\n";
            // terminates the row/line in the CSV file
        }
        // Get the most number of products and create a header for them
        $headers3 = array();
        for ($i = 0; $i < $count; $i++) {
//.........这里部分代码省略.........
开发者ID:osuarcher,项目名称:WP-e-Commerce,代码行数:101,代码来源:init.php


注:本文中的wpsc_get_state_by_id函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。