custom-fields

Dynamic checkout custom fields per persons and items in Woocommerce bookings

折月煮酒 提交于 2021-02-18 17:55:44
问题 For a bookings website I'm trying to create a function which makes it possible to add an attendee list, based on the amount of persons. I've already got the code for a single booking, thanks to LoicTheAztec. That part is working fine. I also need the same functionality for multiple bookings. How can I achieve this? Here is the code: //* Add a new checkout field add_filter( 'woocommerce_checkout_fields', 'ppp_filter_checkout_fields' ); function ppp_filter_checkout_fields($fields){ $fields[

Display WooCommerce custom product field meta data in Cart and on Checkout

南笙酒味 提交于 2021-02-10 23:39:52
问题 I've created a custom product field (admin). The field works fine and it saves the data just fine. What I am having problems with it is adding the meta data to the cart and checkout. I get no errors (debug turned on in wp-config ), no notices -- nothing. In the cart and on checkout, no data is shown. This is my code: add_action( 'woocommerce_product_options_general_product_data', 'product_delivery_time' ); function product_delivery_time(){ global $woocommerce, $post; echo '<div class="product

Add a custom field to an order in WooCommerce 3+

十年热恋 提交于 2021-02-10 14:18:02
问题 In WooCommerce, I would like to add a new custom field to order details. I now that I can use use the code below to create a new custom field 'referenceNumber' and adds in it "ordercreated" value: update_post_meta($order_id, 'referenceNumber', 'ordercreated']); What I would like is to make that through checkout once an order is placed. But it doesn't work it doesn't add a new custom field to order details page and don't add the value 'ordercreated', as you can see in this screenshot: So the

Set a min unit displayed price for simple products too in Woocommerce

故事扮演 提交于 2021-02-08 06:44:28
问题 In Woocommerce I would like to show a minimum price for a simple product and variable products in front of the catalog. Based on "Set a min unit displayed price for variable products in Woocommerce" answer code, where I have made light changes to the last function as follow: // Frontend: Display the min price with "From" prefix label for variable products add_filter( 'woocommerce_variable_price_html', 'custom_min_unit_variable_price_html', 30, 2 ); function custom_min_unit_variable_price_html

Disable editing specific admin custom fields in Woocommerce

坚强是说给别人听的谎言 提交于 2021-02-08 04:27:29
问题 I have some custom fields for my Woocommerce products inside my Inventory Tab using woocommerce_wp_text_input() function. I would like to add one more custom text field just for displaying a value for reference. I want to lock the textfield by default so as not to be able to write something in it. Is it possible? 回答1: Yes it is possible adding the as custom_attributes the readonly property in the field arguments array using: 'custom_attributes' => array('readonly' => 'readonly'), So your code

Order custom fields not displayed on WooCommerce email notifications

烂漫一生 提交于 2021-02-04 08:13:03
问题 I wrote a little plugin that adds a couple of custom fields on checkout page. The fields are related to B2B buyers so they can input Company name, license number and address. Everything pretty much works fine, except the values are not being displayed in order emails, most importantly, order completed email. Here is the part of code I'm having trouble with add_filter('woocommerce_email_order_meta_fields', 'mx_woocommerce_email_order_meta_fields'); function mx_woocommerce_email_order_meta

Override woocommerce cart item price with product custom field value

时间秒杀一切 提交于 2021-02-04 07:36:33
问题 In woocommerce I am using Advanced Custom Fields and trying to get a custom field value in each product as price instead of the default product price. this custom field is called 'custom_price' . How can I change this hard coded value to use that instead? Here is my code: add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' ); function add_custom_price( $cart_object ) { $custom_price = 10; foreach ( $cart_object->cart_contents as $key => $value ) { $value['data']->set_price(

Override woocommerce cart item price with product custom field value

筅森魡賤 提交于 2021-02-04 07:36:03
问题 In woocommerce I am using Advanced Custom Fields and trying to get a custom field value in each product as price instead of the default product price. this custom field is called 'custom_price' . How can I change this hard coded value to use that instead? Here is my code: add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' ); function add_custom_price( $cart_object ) { $custom_price = 10; foreach ( $cart_object->cart_contents as $key => $value ) { $value['data']->set_price(

Multi checkbox fields in Woocommerce backend

梦想的初衷 提交于 2021-02-02 02:08:23
问题 Ive been trying to add a custom field in woocommerce backend where users can multiselect checkboxes for a certain level. Is it possible to create multiple checkboxes? So far i have this: woocommerce_wp_checkbox( array( 'id' => '_custom_product_niveau_field', 'type' => 'checkbox', 'label' => __('Niveau', 'woocommerce'), 'options' => array( 'MBO' => __( 'MBO', 'woocommerce' ), 'HBO' => __( 'HBO', 'woocommerce' ), 'WO' => __( 'WO', 'woocommerce' ) ) ) But that doesnt work... Does woocommerce_wp

Multi checkbox fields in Woocommerce backend

北城以北 提交于 2021-02-02 02:04:50
问题 Ive been trying to add a custom field in woocommerce backend where users can multiselect checkboxes for a certain level. Is it possible to create multiple checkboxes? So far i have this: woocommerce_wp_checkbox( array( 'id' => '_custom_product_niveau_field', 'type' => 'checkbox', 'label' => __('Niveau', 'woocommerce'), 'options' => array( 'MBO' => __( 'MBO', 'woocommerce' ), 'HBO' => __( 'HBO', 'woocommerce' ), 'WO' => __( 'WO', 'woocommerce' ) ) ) But that doesnt work... Does woocommerce_wp