custom-fields

Save and display order custom meta data in Woocommerce 3+

让人想犯罪 __ 提交于 2019-12-11 02:42:17
问题 A while back my partner helped me to add a custom field to our checkout page, we wanted to ask people "How did you hear about us?" when they booked for our events. We put it together but shortly after we stopped being able to see the results properly. In the "New Order" emails sent to the admin, the label 'How did you hear about us' appears, but with no answer. In the order page, it appears in two places: 1) under the Billing info. The label is there. Value is: Array 2) under "Custom Fields"

Remove a checkout field if cart items are from some specific product categories

喜欢而已 提交于 2019-12-11 01:46:13
问题 I use WooCommerce Checkout Manager to add a custom field in my billing section, but I need to show this field only if I have some product from a specified category. The fields is required. I wrote this code : add_filter( 'woocommerce_checkout_fields' , 'wc_ninja_remove_checkout_field'); function wc_ninja_remove_checkout_field( $fields ) { $categories = array( 'prodotti-in-polvere-e-bustine', 'gel-e-creme', 'prodotti-in-capsule', 'prodotti-plantari', 'prodotti-liquidi', 'area-riservata' ); if

Custom editable field in Woocommerce admin edit order pages general section

拜拜、爱过 提交于 2019-12-11 01:13:33
问题 In Woocommerce, the code below retrieves specific custom order item meta data and adds an editable custom field in the admin edit orders pages, under general section area: function editable_order_meta_general( $order_id ){ $order = wc_get_order( $order_id ); // Loop through order items foreach( $order->get_items() as $item_id => $item ){ $yourref = $item->get_meta('Your Reference'); } ?> <br class="clear" /> <h4>Customer Details <a href="#" class="edit_address">Edit</a></h4> <div class=

Add custom fields to custom product calculated price in Woocommerce

ぃ、小莉子 提交于 2019-12-11 00:47:47
问题 In Woocommerce, I added some custom fields to my product single pages, based on this answer code: Add a custom product calculated price to Woocommerce cart. This is my code: // Add a custom field before single add to cart add_action( 'woocommerce_before_add_to_cart_button', 'custom_product_price_field', 5 ); function custom_product_price_field(){ echo '<div class="custom-text text"> <h3>Rental</h3> <label>Start Date:</label> <input type="date" name="rental_date" value="" class="rental_date" /

Get a custom field array values within WooCommerce email order meta

老子叫甜甜 提交于 2019-12-09 04:49:26
I am using the FooEvents plugin to capture event attendee information on WooCommerce event products. When an order is placed, that plugin is saving the attendee information to the WooCommerce order meta as a custom field Array. Using the Post Meta Inspector plugin, I am able to see that the attendee information is being saved as a meta key of WooCommerceEventsOrderTickets and with a value of: 'a:1:{i:1;a:1:{i:1;a:18:{s:26:"WooCommerceEventsProductID";i:454;s:24:"WooCommerceEventsOrderID";i:4609;s:27:"WooCommerceEventsTicketType";s:0:"";s:23:"WooCommerceEventsStatus";s:6:"Unpaid";s:27:

Capture custom checkout field value in Woocommerce

拟墨画扇 提交于 2019-12-08 18:16:28
Im on woocommerce and are trying by snipets, get the value of all fields to send to adroid app with json. The trouble its, that i cant capture the values of custom fields on check out. I tried by plugin and snippet create the field but, i cant recover the values to send to json the field was created with that snipet add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' ); function my_custom_checkout_field( $checkout ) { echo '<div id="my_custom_checkout_field"><h2>' . __('My Field') . '</h2>'; woocommerce_form_field( 'my_field_name', array( 'type' => 'text', 'class' => array(

Adding a custom email recipient depending on selected custom checkout field value

試著忘記壹切 提交于 2019-12-08 15:25:33
I need for Woocommerce to send a custom email to different individuals depending on the option selected for Field Checkout (technically, the custom field is the person reporting on the product variant they have purchased, but I was not sure how to customize email receipt based on product variant purchased, so it is as follows). First I established the custom field using the following code /** * Add the field to the checkout */ add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' ); function my_custom_checkout_field( $checkout ) { echo '<div id="my_custom_checkout_field"><h2>

Display a product custom field value in WooCommerce cart and checkout table

不想你离开。 提交于 2019-12-08 10:38:14
问题 In WooCommerce and I have added a custom field "description" for each product. I was able to find a way to show both, the label name and the value: add_filter( 'woocommerce_add_cart_item_data', 'save_days_field', 10, 2 ); function save_days_field( $cart_item_data, $product_id ) { $special_item = get_post_meta( $product_id , 'description',true ); if(!empty($special_item)) { $cart_item_data[ 'description' ] = $special_item; // below statement make sure every add to cart action as unique line

Non-unique term slugs, or anything else I can use to build specific pages and permalinks?

佐手、 提交于 2019-12-08 05:43:44
问题 My project is a directory of business listings. Individual listing URL looks as simple as domain.com/five-star-cars - something that WordPress handles out of the box. But I have a problem drilling into region-based archives. We need a specific URL structure for those. For example, if we want to show all listings in Ohio, we need domain.com/ohio - also simple. However, if we want to show all listings in Cleveland, Ohio and Cleveland, Nevada - we want to do this: domain.com/cleveland/oh domain

Disabling Add to Cart Button for Specific WooCommerce Products

断了今生、忘了曾经 提交于 2019-12-08 05:09:57
问题 I'm trying to disable adding to cart certain products which have the "Call to Order" checkbox ticked (see code below) on the product editor. add_action( 'woocommerce_product_options_general_product_data', 'custom_general_product_data_custom_fields' ); /** * Add `Call to Order` field in the Product data's General tab. */ function custom_general_product_data_custom_fields() { // Checkbox. woocommerce_wp_checkbox( array( 'id' => '_not_ready_to_sell', 'wrapper_class' => 'show_if_simple', 'label'