本文整理汇总了PHP中wc_edit_address_i18n函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_edit_address_i18n函数的具体用法?PHP wc_edit_address_i18n怎么用?PHP wc_edit_address_i18n使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_edit_address_i18n函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output
/**
* Output the shortcode.
*
* @access public
* @param array $atts
* @return void
*/
public static function output($atts)
{
global $wp;
// Check cart class is loaded or abort
if (is_null(WC()->cart)) {
return;
}
if (!is_user_logged_in()) {
$message = apply_filters('woocommerce_my_account_message', '');
if (!empty($message)) {
wc_add_notice($message);
}
if (isset($wp->query_vars['lost-password'])) {
self::lost_password();
} else {
wc_get_template('myaccount/form-login.php');
}
} else {
if (!empty($wp->query_vars['view-order'])) {
self::view_order(absint($wp->query_vars['view-order']));
} elseif (isset($wp->query_vars['edit-account'])) {
self::edit_account();
} elseif (isset($wp->query_vars['edit-address'])) {
self::edit_address(wc_edit_address_i18n(sanitize_title($wp->query_vars['edit-address']), true));
} elseif (isset($wp->query_vars['add-payment-method'])) {
self::add_payment_method();
} else {
self::my_account($atts);
}
}
}
示例2: wc_get_endpoint_url
/**
* Get endpoint URL.
*
* Gets the URL for an endpoint, which varies depending on permalink settings.
*
* @param string $endpoint
* @param string $value
* @param string $permalink
*
* @return string
*/
function wc_get_endpoint_url($endpoint, $value = '', $permalink = '')
{
if (!$permalink) {
$permalink = get_permalink();
}
// Map endpoint to options
$endpoint = !empty(WC()->query->query_vars[$endpoint]) ? WC()->query->query_vars[$endpoint] : $endpoint;
$value = 'edit-address' == $endpoint ? wc_edit_address_i18n($value) : $value;
if (get_option('permalink_structure')) {
if (strstr($permalink, '?')) {
$query_string = '?' . parse_url($permalink, PHP_URL_QUERY);
$permalink = current(explode('?', $permalink));
} else {
$query_string = '';
}
$url = trailingslashit($permalink) . $endpoint . '/' . $value . $query_string;
} else {
$url = add_query_arg($endpoint, $value, $permalink);
}
return apply_filters('woocommerce_get_endpoint_url', $url, $endpoint, $value, $permalink);
}
示例3: save_address
/**
* Save and and update a billing or shipping address if the
* form was submitted through the user account page.
*/
public static function save_address()
{
global $wp;
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
if (empty($_POST['action']) || 'edit_address' !== $_POST['action'] || empty($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'woocommerce-edit_address')) {
return;
}
$user_id = get_current_user_id();
if ($user_id <= 0) {
return;
}
$load_address = isset($wp->query_vars['edit-address']) ? wc_edit_address_i18n(sanitize_title($wp->query_vars['edit-address']), true) : 'billing';
$address = WC()->countries->get_address_fields(esc_attr($_POST[$load_address . '_country']), $load_address . '_');
foreach ($address as $key => $field) {
if (!isset($field['type'])) {
$field['type'] = 'text';
}
// Get Value.
switch ($field['type']) {
case 'checkbox':
$_POST[$key] = (int) isset($_POST[$key]);
break;
default:
$_POST[$key] = isset($_POST[$key]) ? wc_clean($_POST[$key]) : '';
break;
}
// Hook to allow modification of value.
$_POST[$key] = apply_filters('woocommerce_process_myaccount_field_' . $key, $_POST[$key]);
// Validation: Required fields.
if (!empty($field['required']) && empty($_POST[$key])) {
wc_add_notice(sprintf(__('%s is a required field.', 'woocommerce'), $field['label']), 'error');
}
if (!empty($_POST[$key])) {
// Validation rules.
if (!empty($field['validate']) && is_array($field['validate'])) {
foreach ($field['validate'] as $rule) {
switch ($rule) {
case 'postcode':
$_POST[$key] = strtoupper(str_replace(' ', '', $_POST[$key]));
if (!WC_Validation::is_postcode($_POST[$key], $_POST[$load_address . '_country'])) {
wc_add_notice(__('Please enter a valid postcode / ZIP.', 'woocommerce'), 'error');
} else {
$_POST[$key] = wc_format_postcode($_POST[$key], $_POST[$load_address . '_country']);
}
break;
case 'phone':
$_POST[$key] = wc_format_phone_number($_POST[$key]);
if (!WC_Validation::is_phone($_POST[$key])) {
wc_add_notice(sprintf(__('%s is not a valid phone number.', 'woocommerce'), '<strong>' . $field['label'] . '</strong>'), 'error');
}
break;
case 'email':
$_POST[$key] = strtolower($_POST[$key]);
if (!is_email($_POST[$key])) {
wc_add_notice(sprintf(__('%s is not a valid email address.', 'woocommerce'), '<strong>' . $field['label'] . '</strong>'), 'error');
}
break;
}
}
}
}
}
do_action('woocommerce_after_save_address_validation', $user_id, $load_address, $address);
if (0 === wc_notice_count('error')) {
foreach ($address as $key => $field) {
update_user_meta($user_id, $key, $_POST[$key]);
}
wc_add_notice(__('Address changed successfully.', 'woocommerce'));
do_action('woocommerce_customer_save_address', $user_id, $load_address);
wp_safe_redirect(wc_get_endpoint_url('edit-address', '', wc_get_page_permalink('myaccount')));
exit;
}
}
示例4: woocommerce_account_edit_address
/**
* My Account > Edit address template.
*
* @param string $type Address type.
*/
function woocommerce_account_edit_address($type)
{
$type = wc_edit_address_i18n(sanitize_title($type), true);
WC_Shortcode_My_Account::edit_address($type);
}
示例5: saphali_custom_edit_address_fields
function saphali_custom_edit_address_fields($fields)
{
global $wp;
$fieldss = get_option('woocommerce_saphali_filds_filters');
if (is_array($fieldss)) {
$_fields = $fieldss["billing"];
}
if (isset($_fields) && is_array($_fields)) {
foreach ($_fields as $key => $value) {
if (str_replace('billing_', '', $key) != 'email') {
$__fields[wc_edit_address_i18n(sanitize_key($wp->query_vars['edit-address']), true) . str_replace('billing', '', $key)] = $value;
}
$_a_ = array_diff_assoc($__fields, $fields);
if (is_array($_a_) && is_array($fields)) {
$fields = (array) $fields + (array) $_a_;
}
}
}
return $fields;
}