hook-woocommerce

How to add a (second) custom sku field to WooCommerce products?

巧了我就是萌 提交于 2020-07-21 06:17:27
问题 We needed another field in our products for Prod ref/Cat numbers and I found the bit of code below which works perfectly. I now need to add a second field for Nominal Codes used by the accountants software. I tried using the below code again, adjusted for the new field, but it didn't work. function jk_add_custom_sku() { $args = array( 'label' => __( 'Custom SKU', 'woocommerce' ), 'placeholder' => __( 'Enter custom SKU here', 'woocommerce' ), 'id' => 'jk_sku', 'desc_tip' => true, 'description'

Exclude certain categories when automatically adding products to the cart WooCommerce

冷暖自知 提交于 2020-07-16 03:25:32
问题 In WooCommerce, I use a code that auto adds packaging when adding any dish to the cart. function add_delivery_charge_to_cart( $cart ) { if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 ) return; $lunchbox_id = 5737; // "LunchBox" to be added to cart $pakket_id = 5738; // "Pakket" to be added to cart // Loop through cart items foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) { // Check if "LunchBox" product is

How to add Meta Title and Meta Description in WooCommerce category page

℡╲_俬逩灬. 提交于 2020-07-15 09:17:09
问题 I am using All in one SEO Pack plugin for Meta Title & Meta Description for my website. My website having WooCommerce and All in one SEO pack does not support Meta Title & Meta Description for WooCommerce categories page. So I have used below code to create custom fields for Meta Title & Meta Description for WooCommerce categories in admin area. function wh_taxonomy_add_new_meta_field() { ?> <div class="form-field"> <label for="wh_meta_title"><?php _e('Meta Title', 'wh'); ?></label> <input

How to add Meta Title and Meta Description in WooCommerce category page

北城以北 提交于 2020-07-15 09:16:31
问题 I am using All in one SEO Pack plugin for Meta Title & Meta Description for my website. My website having WooCommerce and All in one SEO pack does not support Meta Title & Meta Description for WooCommerce categories page. So I have used below code to create custom fields for Meta Title & Meta Description for WooCommerce categories in admin area. function wh_taxonomy_add_new_meta_field() { ?> <div class="form-field"> <label for="wh_meta_title"><?php _e('Meta Title', 'wh'); ?></label> <input

Display “In Stock” notice for WooCommerce variations with no Managed Stock

旧时模样 提交于 2020-07-15 09:00:08
问题 I need help for a particular situation. In WooCommerce, if "Manage Stock" is enabled for a simple product or variation, then a notification is being displayed in the product page => such as [this example][1] However, if "Manage Stock" is not enabled, then there is no notification which I find it a pity because I still want to inform my customers that it's precisely in stock even if I don't manage the stock quantities. I've found the below code. For simple products, it works without any

Display SKU on the 'additional information area' for single and variable products

两盒软妹~` 提交于 2020-07-09 14:46:52
问题 I'm trying to display the product's SKU inside the table row of single products Additional Information tab. I tried using the woocommerce_display_product_attributes filter and have it displayed (sample of my code below) but it only works with simple product . When using variable products with different SKU, the field are not updated when (dropdown select) variation is selected and only show blank. Is there a proper way to do this? Here's my current code: // Displays SKU/Part# to Single

In Woocommerce order page, create a custom text field related to order id

本秂侑毒 提交于 2020-07-09 08:50:35
问题 In this code comes come an answer to one of my previous questions, and the custom url data is related to the user data. I need that the custom url have to be different, related to the order id (ex. 100 order, 100 different custom url, one per order's page). // Display user custom field add_action( 'woocommerce_order_details_before_order_table', 'add_user_custom_url_field_to_order' ); function add_user_custom_url_field_to_order( $order ) { global $current_user; $custom_url = get_user_meta(

In Woocommerce order page, create a custom text field related to order id

穿精又带淫゛_ 提交于 2020-07-09 08:48:28
问题 In this code comes come an answer to one of my previous questions, and the custom url data is related to the user data. I need that the custom url have to be different, related to the order id (ex. 100 order, 100 different custom url, one per order's page). // Display user custom field add_action( 'woocommerce_order_details_before_order_table', 'add_user_custom_url_field_to_order' ); function add_user_custom_url_field_to_order( $order ) { global $current_user; $custom_url = get_user_meta(

WooCommerce: check if product has attribute

只谈情不闲聊 提交于 2020-07-08 21:33:30
问题 I'm trying to append text to products that cointain the attribute "pa_sprog" value "dansk" I am working from this post this is what I have so far: add_action( 'woocommerce_before_add_to_cart_form', 'flag1' ); function flag1() { $product = wc_get_product( $product_id ); // Get the product attribute value $sprog = $product->get_attribute('pa_sprog'); // if product has attribute 'sprog' value(s) if( $sprog="dansk" ){ echo '<div class="">"Dansk!"</div>'; } else { // Engelsk } } 回答1: Give it a try

WooCommerce: check if product has attribute

拜拜、爱过 提交于 2020-07-08 21:31:30
问题 I'm trying to append text to products that cointain the attribute "pa_sprog" value "dansk" I am working from this post this is what I have so far: add_action( 'woocommerce_before_add_to_cart_form', 'flag1' ); function flag1() { $product = wc_get_product( $product_id ); // Get the product attribute value $sprog = $product->get_attribute('pa_sprog'); // if product has attribute 'sprog' value(s) if( $sprog="dansk" ){ echo '<div class="">"Dansk!"</div>'; } else { // Engelsk } } 回答1: Give it a try