php Woocommerce提供免费无线网络连接1странице
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Woocommerce提供免费无线网络连接1странице相关的知识,希望对你有一定的参考价值。
<?php
/*
* Custom Checkout Form
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
wc_print_notices();
$checkout = WC()->checkout();
$customer_id = get_current_user_id();
// If checkout registration is disabled and not logged in, the user cannot checkout
if ( ! $checkout->enable_signup && ! $checkout->enable_guest_checkout && ! is_user_logged_in() ) {
echo apply_filters( 'woocommerce_checkout_must_be_logged_in_message', __( 'You must be logged in to checkout.', 'woocommerce' ) );
return;
}
?>
<h2 class="entry-title">Оформление заказа</h2>
<form name="checkout" method="post" class="checkout woocommerce-checkout form-horizontal" action="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" enctype="multipart/form-data">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="billing_first_name" class="control-label col-md-3"><?php _e( 'First name', 'woocommerce' ); ?></label>
<div class="col-md-9">
<input type="text" class="input-text form-control" name="billing_first_name" id="billing_firts_name" required="required" placeholder="" value="<?php esc_attr_e( get_address_field_value($customer_id, 'billing_first_name') ); ?>">
</div>
</div>
<div class="form-group">
<label for="billing_phone" class="control-label col-md-3"><?php _e( 'Phone', 'woocommerce' ); ?></label>
<div class="col-md-9">
<input type="text" class="input-text form-control" name="billing_phone" id="billing_phone" required="required" placeholder="" value="<?php esc_attr_e( get_address_field_value($customer_id, 'billing_phone') ); ?>">
</div>
</div>
<div class="form-group">
<label for="account_email" class="control-label col-md-3"><?php _e( 'Email address', 'woocommerce' ); ?></label>
<div class="col-md-9">
<input type="email" class="input-text form-control" name="billing_email" id="billing_email" required="required" placeholder="" value="<?php esc_attr_e( get_address_field_value($customer_id, 'billing_email') ); ?>" />
</div>
</div>
<div class="form-group">
<div class="col-md-9 col-md-offset-3 checkout-submit">
<?php wp_nonce_field( 'woocommerce-process_checkout' ); ?>
<input type="submit" class="btn btn-submit" name="woocommerce_checkout_place_order" id="place_order" value="Оформить заказ" data-value="Оформить заказ" />
</div>
</div>
</div>
</div>
</form>
<?php
/*
Plugin Name: Woocommerce Simplify checkout
Plugin URI: https://github.com/systemo-biz/woocommerce-simplify-checkout/
Description: Уменьшает кол-во полей чекаута и переносит в корзину
Author: Александр Павлюков
License: GNU General Public License v2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
GitHub Plugin URI: https://github.com/systemo-biz/woocommerce-simplify-checkout/
GitHub Branch: master
Version: 20160404
*/
// Отключаем выбор типа оплаты
add_filter('woocommerce_cart_needs_payment', '__return_false');
// Отключаем выбор способа доставки
add_filter('woocommerce_cart_needs_shipping', '__return_false');
// Убираем ненужные поля
add_filter( 'woocommerce_checkout_fields' , 'remove_extra_checkout_fields' );
function remove_extra_checkout_fields( $fields ) {
unset( $fields['billing']['billing_last_name'] );
unset( $fields['billing']['billing_company'] );
unset( $fields['billing']['billing_address_1'] );
unset( $fields['billing']['billing_address_2'] );
unset( $fields['billing']['billing_city'] );
unset( $fields['billing']['billing_postcode'] );
unset( $fields['billing']['billing_country'] );
unset( $fields['billing']['billing_state'] );
unset( $fields['shipping']['shipping_first_name'] );
unset( $fields['shipping']['shipping_last_name'] );
unset( $fields['shipping']['shipping_company'] );
unset( $fields['shipping']['shipping_address_1'] );
unset( $fields['shipping']['shipping_address_2'] );
unset( $fields['shipping']['shipping_city'] );
unset( $fields['shipping']['shipping_postcode'] );
unset( $fields['shipping']['shipping_country'] );
unset( $fields['shipping']['shipping_state'] );
unset( $fields['account']['account_username'] );
unset( $fields['account']['account_password'] );
unset( $fields['account']['account_password-2'] );
unset( $fields['order']['order_comments'] );
return $fields;
}
// Функция для получения значения опред. поля адреса клиента
if ( !function_exists( 'get_address_field_value' ) ) {
function get_address_field_value($customer_id, $field_name) {
$load_address = 'billing';
$address = WC()->countries->get_address_fields( get_user_meta( $customer_id, $load_address . '_country', true ), $load_address . '_' );
foreach ( $address as $key => $field ) {
$value = get_user_meta( get_current_user_id(), $key, true );
if ( ! $value ) {
switch( $key ) {
case 'billing_email' :
$value = $current_user->user_email;
break;
}
}
$address[ $key ]['value'] = apply_filters( 'woocommerce_my_account_edit_address_field_value', $value, $key, $load_address );
}
return ( !empty( $address[$field_name]['value'] ) ) ? $address[$field_name]['value'] : '' ;
}
}
// Убираем из корзины переход в чекаут и ставим свою форму
add_action( 'woocommerce_cart_collaterals', 'custom_checkout_form', 1 );
function custom_checkout_form() {
remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cart_totals', 10 );
load_template( plugin_dir_path( __FILE__ ) . 'templates/form-checkout.php', true );
}
以上是关于php Woocommerce提供免费无线网络连接1странице的主要内容,如果未能解决你的问题,请参考以下文章
当 WooCommerce 3 中提供免费送货时,隐藏细节统一费率
php 如果在结账时使用优惠券,请删除WooCommerce中的免费送货服务
WooCommerce - 当免费送货可用时隐藏其他送货方式