php 返回商店重定向#woo

将购物车中的“返回商店”按钮重定向到列出待售产品的集合类别中:<br/> **来源:** https://docs.woocommerce.com/document/tutorial-customising- checkout-fields-using-actions-and-filters / <br> <br/>![返回商店按钮](https://s9900.pcdn.co/wp-content/uploads/2014/11/woocommerce-empty -cart.png“返回商店按钮”)

functions.php
// Changes the redirect URL for the Return To Shop button in the cart.
function empty_cart_redirect_url() {
\!h  return '__http://example.url/category/specials/__'; 
}
add_filter( 'woocommerce_return_to_shop_redirect', 'empty_cart_redirect_url', 20 );

php 产品附加组件

functions.php
// 1. Show custom input field above Add to Cart
 
add_action( 'woocommerce_before_add_to_cart_button', 'bbloomer_product_add_on', 9 );
 
function bbloomer_product_add_on() {
	if ( is_product() && has_term( array (
		'cordless-drills',
		'domino-joiners',
		'dust-extractors',
		'edge-banders',
		'jigsaws',
		'kapex-miter-saws',
		'mft-tables',
		'planers',
		'routers',
		'sanders',
		'track-saws'),
								  	'product_cat' ) )
		
	 {
    $value = isset( $_POST['_tshirt_add_on'] ) ? sanitize_text_field( $_POST['_tshirt_add_on'] ) : '';
    echo '<shirt><label>FREE T-Shirt with Power Tool<Br /> (please specify size M, L, XL, XXL) </label><p><input name="_tshirt_add_on" value="' . $value . '"></p></shirt>';
	}
}
 
// -----------------------------------------
// 2. Throw error if custom input field empty
 
add_filter( 'woocommerce_add_to_cart_validation', 'bbloomer_product_add_on_validation', 10, 3 );
 
function bbloomer_product_add_on_validation( $passed, $product_id, $qty ){
   if( isset( $_POST['_tshirt_add_on'] ) && sanitize_text_field( $_POST['_tshirt_add_on'] ) == '' ) {
      wc_add_notice( 'T-shirt is a required field', 'error' );
      $passed = false;
   }
    return $passed;
}
 
// -----------------------------------------
// 3. Save custom input field value into cart item data
 
add_filter( 'woocommerce_add_cart_item_data', 'bbloomer_product_add_on_cart_item_data', 10, 2 );
 
function bbloomer_product_add_on_cart_item_data( $cart_item, $product_id ){
    if( isset( $_POST['_tshirt_add_on'] ) ) {
        $cart_item['tshirt_add_on'] = sanitize_text_field( $_POST['_tshirt_add_on'] );
    }
    return $cart_item;
}
 
// -----------------------------------------
// 4. Display custom input field value @ Cart
 
add_filter( 'woocommerce_get_item_data', 'bbloomer_product_add_on_display_cart', 10, 2 );
 
function bbloomer_product_add_on_display_cart( $_data, $cart_item ) {
    if ( isset( $cart_item['tshirt_add_on'] ) ){
        $data[] = array(
            'name' => 'ShirtSize',
            'value' => 'T-Shirt:' . sanitize_text_field( $cart_item['tshirt_add_on'] )
        );
    }
    return $data;
}
 
// -----------------------------------------
// 5. Save custom input field value into order item meta
 
add_action( 'woocommerce_add_order_item_meta', 'bbloomer_product_add_on_order_item_meta', 10, 2 );
 
function bbloomer_product_add_on_order_item_meta( $item_id, $values ) {
    if ( ! empty( $values['tshirt_add_on'] ) ) {
        wc_add_order_item_meta( $item_id, 'T-Shirt Size', $values['tshirt_add_on'], true );
    }
}
 
// -----------------------------------------
// 6. Display custom input field value into order table
 
add_filter( 'woocommerce_order_item_product', 'bbloomer_product_add_on_display_order', 10, 2 );
 
function bbloomer_product_add_on_display_order( $cart_item, $order_item ){
    if( isset( $order_item['tshirt_add_on'] ) ){
        $cart_item_meta['tshirt_add_on'] = $order_item['tshirt_add_on'];
    }
    return $cart_item;
}
 
// -----------------------------------------
// 7. Display custom input field value into order emails
 
add_filter( 'woocommerce_email_order_meta_fields', 'bbloomer_product_add_on_display_emails' );
 
function bbloomer_product_add_on_display_emails( $fields ) { 
    $fields['tshirt_add_on'] = 'T-Shirt Size';
    return $fields; 
}

php Woo Checkout Fields&Arrays #woo

可以通过过滤器传递的默认Woocommerce结帐字段和属性的完整列表。

functions.php
/*Default Woocommerce Checkout Fields & properties:
  Array of overridable properties:
    type – type of field (text, textarea, password, select)
    label – label for the input field
    placeholder – placeholder for the input
    class – class for the input
    required – true or false, whether or not the field is require
    clear – true or false, applies a clear fix to the field/label
    label_class – class for the label element
    options – for select boxes, array of options (key => value pairs)

  Hook: woocommerce_checkout_fields
      Billing
          billing_first_name
          billing_last_name
          billing_company
          billing_address_1
          billing_address_2
          billing_city
          billing_postcode
          billing_country
          billing_state
          billing_email
          billing_phone
      Shipping
          shipping_first_name
          shipping_last_name
          shipping_company
          shipping_address_1
          shipping_address_2
          shipping_city
          shipping_postcode
          shipping_country
          shipping_state
      Account
          account_username
          account_password
          account_password-2
      Order
          order_comments    
          
  Billing & Shipping Hook: woocommerce_default_address_fields
      country
      first_name
      last_name
      company
      address_1
      address_2
      city
      state
      postcode  
*/

php 源缩略图图像响应 - Responsiva

php.php
$evento_banner_desktop = wp_get_attachment_image_src( get_post_thumbnail_id($id), 'evento-banner-desktop' );  
$evento_banner_tablet = wp_get_attachment_image_src( get_post_thumbnail_id($id), 'evento-banner-tablet' );  
$evento_banner_mobile = wp_get_attachment_image_src( get_post_thumbnail_id($id), 'evento-banner-mobile' );  

echo '
<picture>
    <source srcset="'.$evento_banner_desktop[0].'" media="(min-width: 850px)" />
    <source srcset="'.$evento_banner_tablet[0].'" media="(min-width: 768px)" />
    <img srcset="'.$evento_banner_mobile[0].'" />        
</picture>
';

php Лимитнаразмерзагрузкуфала

wp-config.php
define('WP_MEMORY_LIMIT', '128M');

php 测试

test.js
console.log("Hello world")
test.php
<?php
  echo "Hello World";
?>

php 测试

test.js
console.log("Hello world")
test.php
<?php
  echo "Hello World";
?>

php 测试

test.js
console.log("Hello world")
test.php
<?php
  echo "Hello World";
?>

php 测试

test.js
console.log("Hello world")
test.php
<?php
  echo "Hello World";
?>

php 测试

test.js
console.log("Hello world")
test.php
<?php
  echo "Hello World";
?>