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


PHP wc_array_overlay函数代码示例

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


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

示例1: woocommerce_array_overlay

/**
 * @deprecated
 */
function woocommerce_array_overlay($a1, $a2)
{
    return wc_array_overlay($a1, $a2);
}
开发者ID:nayemDevs,项目名称:woocommerce,代码行数:7,代码来源:wc-deprecated-functions.php

示例2: get_address_fields

 /**
  * Apply locale and get address fields.
  * @param  mixed  $country (default: '')
  * @param  string $type (default: 'billing_')
  * @return array
  */
 public function get_address_fields($country = '', $type = 'billing_')
 {
     if (!$country) {
         $country = $this->get_base_country();
     }
     $fields = $this->get_default_address_fields();
     $locale = $this->get_country_locale();
     if (isset($locale[$country])) {
         $fields = wc_array_overlay($fields, $locale[$country]);
     }
     // Prepend field keys
     $address_fields = array();
     foreach ($fields as $key => $value) {
         $keys = array_keys($fields);
         $address_fields[$type . $key] = $value;
         // Add email and phone after company or last
         if ($type == 'billing_' && ('company' === $key || !array_key_exists('company', $fields) && $key === end($keys))) {
             $address_fields['billing_email'] = array('label' => __('Email Address', 'woocommerce'), 'required' => true, 'type' => 'email', 'class' => array('form-row-first'), 'validate' => array('email'));
             $address_fields['billing_phone'] = array('label' => __('Phone', 'woocommerce'), 'required' => true, 'type' => 'tel', 'class' => array('form-row-last'), 'clear' => true, 'validate' => array('phone'));
         }
     }
     $address_fields = apply_filters('woocommerce_' . $type . 'fields', $address_fields, $country);
     return $address_fields;
 }
开发者ID:manuhareendran,项目名称:project,代码行数:30,代码来源:class-wc-countries.php

示例3: wc_array_overlay

/**
 * Merge two arrays.
 *
 * @param array $a1
 * @param array $a2
 * @return array
 */
function wc_array_overlay($a1, $a2)
{
    foreach ($a1 as $k => $v) {
        if (!array_key_exists($k, $a2)) {
            continue;
        }
        if (is_array($v) && is_array($a2[$k])) {
            $a1[$k] = wc_array_overlay($v, $a2[$k]);
        } else {
            $a1[$k] = $a2[$k];
        }
    }
    return $a1;
}
开发者ID:coderkevin,项目名称:woocommerce,代码行数:21,代码来源:wc-formatting-functions.php

示例4: get_address_fields

 /**
  * Apply locale and get address fields
  * @param  mixed  $country
  * @param  string $type (default: 'billing_')
  * @return array
  */
 public function get_address_fields($country = '', $type = 'billing_')
 {
     if (!$country) {
         $country = $this->get_base_country();
     }
     $fields = $this->get_default_address_fields();
     $locale = $this->get_country_locale();
     if (isset($locale[$country])) {
         $fields = wc_array_overlay($fields, $locale[$country]);
     }
     // Prepend field keys
     $address_fields = array();
     foreach ($fields as $key => $value) {
         $address_fields[$type . $key] = $value;
     }
     // Billing/Shipping Specific
     if ($type == 'billing_') {
         $address_fields['billing_email'] = array('label' => __('Email Address', 'woocommerce'), 'required' => true, 'class' => array('form-row-first'), 'validate' => array('email'));
         $address_fields['billing_phone'] = array('label' => __('Phone (Use this format in order to get SMS notifications: 27XXXXXXXX)', 'woocommerce'), 'required' => true, 'class' => array('form-row-last'), 'clear' => true, 'validate' => array('phone'));
     }
     $address_fields = apply_filters('woocommerce_' . $type . 'fields', $address_fields, $country);
     return $address_fields;
 }
开发者ID:etondeengole,项目名称:Store_Application,代码行数:29,代码来源:class-wc-countries.php

示例5: test_wc_array_overlay

 /**
  * Test wc_array_overlay().
  *
  * @since 2.2
  */
 public function test_wc_array_overlay()
 {
     $a1 = array('apple' => 'banana', 'pear' => 'grape', 'vegetables' => array('cucumber' => 'asparagus'));
     $a2 = array('strawberry' => 'orange', 'apple' => 'kiwi', 'vegetables' => array('cucumber' => 'peas'));
     $overlayed = array('apple' => 'kiwi', 'pear' => 'grape', 'vegetables' => array('cucumber' => 'peas'));
     $this->assertEquals($overlayed, wc_array_overlay($a1, $a2));
 }
开发者ID:jimlove7273,项目名称:woocommerce,代码行数:12,代码来源:functions.php

示例6: get_address_fields

 /**
  * Apply locale and get address fields
  *
  * @access public
  * @param mixed $country
  * @param string $type (default: 'billing_')
  * @return array
  */
 public function get_address_fields($country, $type = 'billing_')
 {
     if (!$country) {
         $country = $this->get_base_country();
     }
     $fields = $this->get_default_address_fields();
     $locale = $this->get_country_locale();
     if (isset($locale[$country])) {
         $fields = wc_array_overlay($fields, $locale[$country]);
         // If default country has postcode_before_city switch the fields round.
         // This is only done at this point, not if country changes on checkout.
         if (isset($locale[$country]['postcode_before_city'])) {
             if (isset($fields['postcode'])) {
                 $fields['postcode']['class'] = array('form-row-wide', 'address-field');
                 $switch_fields = array();
                 foreach ($fields as $key => $value) {
                     if ($key == 'city') {
                         // Place postcode before city
                         $switch_fields['postcode'] = '';
                     }
                     $switch_fields[$key] = $value;
                 }
                 $fields = $switch_fields;
             }
         }
     }
     // Prepend field keys
     $address_fields = array();
     foreach ($fields as $key => $value) {
         $address_fields[$type . $key] = $value;
     }
     // Billing/Shipping Specific
     if ($type == 'billing_') {
         $address_fields['billing_email'] = array('label' => __('Email Address', 'woocommerce'), 'required' => true, 'class' => array('form-row-first'), 'validate' => array('email'));
         $address_fields['billing_phone'] = array('label' => __('Phone', 'woocommerce'), 'required' => true, 'class' => array('form-row-last'), 'clear' => true, 'validate' => array('phone'));
     }
     $address_fields = apply_filters('woocommerce_' . $type . 'fields', $address_fields, $country);
     // Return
     return $address_fields;
 }
开发者ID:hoonio,项目名称:PhoneAfrika,代码行数:48,代码来源:class-wc-countries.php

示例7: init_address_fields

 function init_address_fields($b_country = '', $s_country = '', $show_country = true)
 {
     $this->billing_fields = apply_filters('woocommerce_admin_billing_fields', array('first_name' => array('label' => __('First Name', 'woocommerce'), 'show' => false), 'last_name' => array('label' => __('Last Name', 'woocommerce'), 'show' => false), 'company' => array('label' => __('Company', 'woocommerce'), 'show' => false), 'address_1' => array('label' => __('Address 1', 'woocommerce'), 'show' => false), 'address_2' => array('label' => __('Address 2', 'woocommerce'), 'show' => false), 'city' => array('label' => __('City', 'woocommerce'), 'show' => false), 'postcode' => array('label' => __('Postcode', 'woocommerce'), 'show' => false), 'country' => array('label' => __('Country', 'woocommerce'), 'show' => false, 'class' => 'js_field-country select short', 'type' => 'select', 'options' => array('' => __('Select a country…', 'woocommerce')) + WC()->countries->get_allowed_countries()), 'state' => array('label' => __('State/County', 'woocommerce'), 'class' => 'js_field-state select short', 'show' => false), 'email' => array('label' => __('Email', 'woocommerce')), 'phone' => array('label' => __('Phone', 'woocommerce'))));
     $this->shipping_fields = apply_filters('woocommerce_admin_shipping_fields', array('first_name' => array('label' => __('First Name', 'woocommerce'), 'show' => false), 'last_name' => array('label' => __('Last Name', 'woocommerce'), 'show' => false), 'company' => array('label' => __('Company', 'woocommerce'), 'show' => false), 'address_1' => array('label' => __('Address 1', 'woocommerce'), 'show' => false), 'address_2' => array('label' => __('Address 2', 'woocommerce'), 'show' => false), 'city' => array('label' => __('City', 'woocommerce'), 'show' => false), 'postcode' => array('label' => __('Postcode', 'woocommerce'), 'show' => false), 'country' => array('label' => __('Country', 'woocommerce'), 'show' => false, 'type' => 'select', 'class' => 'js_field-country select short', 'options' => array('' => __('Select a country…', 'woocommerce')) + WC()->countries->get_shipping_countries()), 'state' => array('label' => __('State/County', 'woocommerce'), 'class' => 'js_field-state select short', 'show' => false)));
     if (!empty($b_country) || !empty($s_country)) {
         $countries = new WC_Countries();
         $locale = $countries->get_country_locale();
         $state_arr = WC()->countries->get_allowed_country_states();
     }
     if (!empty($b_country)) {
         if (isset($locale[$b_country])) {
             $this->billing_fields = wc_array_overlay($this->billing_fields, $locale[$b_country]);
             // If default country has postcode_before_city switch the fields round.
             // This is only done at this point, not if country changes on checkout.
             if (isset($locale[$b_country]['postcode_before_city'])) {
                 if (isset($this->billing_fields['postcode'])) {
                     $this->billing_fields['postcode']['class'] = array('form-row-wide', 'address-field');
                     $switch_fields = array();
                     foreach ($this->billing_fields as $key => $value) {
                         if ($key == 'city') {
                             // Place postcode before city
                             $switch_fields['postcode'] = '';
                         }
                         $switch_fields[$key] = $value;
                     }
                     $this->billing_fields = $switch_fields;
                 }
             }
             if (isset($state_arr[$b_country]) && !empty($state_arr[$b_country])) {
                 $this->billing_fields['state']['type'] = 'select';
                 $this->billing_fields['state']['class'] = array('form-row-left', 'address-field', 'chosen_select');
                 $this->billing_fields['state']['options'] = $state_arr[$b_country];
             }
         }
     }
     if (!empty($s_country)) {
         if (isset($locale[$s_country])) {
             $this->shipping_fields = wc_array_overlay($this->shipping_fields, $locale[$s_country]);
             // If default country has postcode_before_city switch the fields round.
             // This is only done at this point, not if country changes on checkout.
             if (isset($locale[$s_country]['postcode_before_city'])) {
                 if (isset($this->shipping_fields['postcode'])) {
                     $this->shipping_fields['postcode']['class'] = array('form-row-wide', 'address-field');
                     $switch_fields = array();
                     foreach ($this->shipping_fields as $key => $value) {
                         if ($key == 'city') {
                             // Place postcode before city
                             $switch_fields['postcode'] = '';
                         }
                         $switch_fields[$key] = $value;
                     }
                     $this->shipping_fields = $switch_fields;
                 }
             }
             if (isset($state_arr[$s_country]) && !empty($state_arr[$s_country])) {
                 $this->shipping_fields['state']['type'] = 'select';
                 $this->shipping_fields['state']['class'] = array('form-row-left', 'address-field', 'chosen_select');
                 $this->shipping_fields['state']['options'] = $state_arr[$b_country];
             }
         }
     }
 }
开发者ID:sajidshah,项目名称:le-dolci,代码行数:62,代码来源:wc_crm_customer_details.php

示例8: get_address_fields

 /**
  * Apply locale and get address fields.
  * @param  mixed  $country (default: '')
  * @param  string $type (default: 'billing_')
  * @return array
  */
 public function get_address_fields($country = '', $type = 'billing_')
 {
     if (!$country) {
         $country = $this->get_base_country();
     }
     $fields = $this->get_default_address_fields();
     $locale = $this->get_country_locale();
     if (isset($locale[$country])) {
         $fields = wc_array_overlay($fields, $locale[$country]);
     }
     // Prepend field keys
     $address_fields = array();
     foreach ($fields as $key => $value) {
         $keys = array_keys($fields);
         $address_fields[$type . $key] = $value;
     }
     // Add email and phone fields.
     if ('billing_' === $type) {
         $address_fields['billing_phone'] = array('label' => __('Phone', 'woocommerce'), 'required' => true, 'type' => 'tel', 'class' => array('form-row-first'), 'validate' => array('phone'), 'autocomplete' => 'tel');
         $address_fields['billing_email'] = array('label' => __('Email address', 'woocommerce'), 'required' => true, 'clear' => true, 'type' => 'email', 'class' => array('form-row-last'), 'validate' => array('email'), 'autocomplete' => 'no' === get_option('woocommerce_registration_generate_username') ? 'email' : 'email username');
     }
     /**
      * Important note on this filter: Changes to address fields can and will be overridden by
      * the woocommerce_default_address_fields. The locales/default locales apply on top based
      * on country selection. If you want to change things like the required status of an
      * address field, filter woocommerce_default_address_fields instead.
      */
     $address_fields = apply_filters('woocommerce_' . $type . 'fields', $address_fields, $country);
     return $address_fields;
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:36,代码来源:class-wc-countries.php


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