• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wc_edit_address_i18n函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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);
         }
     }
 }
开发者ID:nightbook,项目名称:woocommerce,代码行数:38,代码来源:class-wc-shortcode-my-account.php


示例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);
}
开发者ID:manuhareendran,项目名称:project,代码行数:32,代码来源:wc-page-functions.php


示例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;
     }
 }
开发者ID:johnulist,项目名称:woocommerce,代码行数:79,代码来源:class-wc-form-handler.php


示例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);
 }
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:10,代码来源:wc-template-functions.php


示例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;
 }
开发者ID:agalardo,项目名称:mal-mala,代码行数:20,代码来源:saphali-woocommerce-lite.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wc_empty_cart函数代码示例发布时间:2022-05-23
下一篇:
PHP wc_dropdown_variation_attribute_options函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap