/** * wpsc_core_load_checkout_data() * * @return none */ function wpsc_core_load_checkout_data() { wpsc_checkout_form_fields(); wpsc_checkout_unique_names(); }
/** * Common routine to put the current customer meta values into an jax * response in a format to be consumed by the wp-e-commerce.js ajax processings * * @since 3.8.14 * @access private * * @param array values being readied to send back to javascript in the json encoded AJAX response * @param string|array|null meta keys to retrieve, if not specified all meta keys are retrieved * @return JSON encoded array with results, results include original request parameters */ function _wpsc_add_customer_meta_to_response($response, $meta_keys = null, $meta_key = 'customer_meta') { if (!empty($meta_keys)) { if (!is_array($meta_keys)) { $meta_keys = array($meta_keys); } } else { $meta_keys = wpsc_checkout_unique_names(); } $customer_meta = array(); foreach ($meta_keys as $a_meta_key) { $customer_meta[$a_meta_key] = wpsc_get_customer_meta($a_meta_key); } $response[$meta_key] = $customer_meta; $response = apply_filters('wpsc_ajax_response_customer_meta', $response); return $response; }
/** * Get the current values for checkout meta * * @since 3.8.14 * @access private * * @param array values being readied to send back to javascript in the json encoded AJAX response * @param string|array|null meta keys to retrieve, if not specified all meta keys are retrieved * @return JSON encoded array with results, results include original request parameters */ function _wpsc_get_checkout_meta($meta_keys = null) { if (!empty($meta_keys)) { if (!is_array($meta_keys)) { $meta_keys = array($meta_keys); } } else { $meta_keys = wpsc_checkout_unique_names(); } $checkout_meta = array(); foreach ($meta_keys as $a_meta_key) { $checkout_meta[$a_meta_key] = wpsc_get_customer_meta($a_meta_key); } return $checkout_meta; }
/** * when visitor meta is updated we need to check if the shipping same as billing * option is selected. If so we need to update the corresponding meta value. * * @since 3.8.14 * @access private * @param $meta_value varies value being stored * @param $meta_key string name of the attribute being stored * @param $visitor_id int id of the visitor to which the attribute applies * @return n/a */ function _wpsc_vistor_shipping_same_as_billing_meta_update($meta_value, $meta_key, $visitor_id) { // remove the action so we don't cause an infinite loop remove_action('wpsc_updated_visitor_meta', '_wpsc_vistor_shipping_same_as_billing_meta_update', _WPSC_USER_META_HOOK_PRIORITY); // if the shipping same as billing option is being checked then copy meta from billing to shipping if ($meta_key == 'shippingSameBilling') { $meta_value = _wpsc_make_value_into_bool($meta_value); if ($meta_value) { $checkout_names = wpsc_checkout_unique_names(); foreach ($checkout_names as $meta_key) { $meta_key_starts_with_billing = strpos($meta_key, 'billing', 0) === 0; if ($meta_key_starts_with_billing) { $other_meta_key_name = 'shipping' . substr($meta_key, strlen('billing')); if (in_array($other_meta_key_name, $checkout_names)) { $billing_meta_value = wpsc_get_customer_meta($meta_key); wpsc_update_visitor_meta($visitor_id, $other_meta_key_name, $billing_meta_value); } } } } } else { $shipping_same_as_billing = wpsc_get_visitor_meta($visitor_id, 'shippingSameBilling', true); if ($shipping_same_as_billing) { $meta_key_starts_with_billing = strpos($meta_key, 'billing', 0) === 0; $meta_key_starts_with_shipping = strpos($meta_key, 'shipping', 0) === 0; if ($meta_key_starts_with_billing) { $checkout_names = wpsc_checkout_unique_names(); $other_meta_key_name = 'shipping' . substr($meta_key, strlen('billing')); if (in_array($other_meta_key_name, $checkout_names)) { wpsc_update_visitor_meta($visitor_id, $other_meta_key_name, $meta_value); } } elseif ($meta_key_starts_with_shipping) { $checkout_names = wpsc_checkout_unique_names(); $other_meta_key_name = 'billing' . substr($meta_key, strlen('shipping')); if (in_array($other_meta_key_name, $checkout_names)) { wpsc_update_visitor_meta($visitor_id, $other_meta_key_name, $meta_value); } } } } // restore the action we removed at the start add_action('wpsc_updated_visitor_meta', '_wpsc_vistor_shipping_same_as_billing_meta_update', _WPSC_USER_META_HOOK_PRIORITY, 3); }