orders

woocommerce_thankyou hook not working

允我心安 提交于 2019-12-09 02:10:19
问题 When I paste the code below directly into the thankyou.php , it works perfectly fine. but when I try to hook it into woocommerce_thankyou , nothing happens. I'm just getting started with PHP, add_action('woocommerce_thankyou', 'test_1', 10, 1); function test_1() { $paymethod = $order->payment_method_title; $orderstat = $order->get_status(); if (($orderstat == 'completed') && ($paymethod == 'PayPal')) { echo "something"; } elseif (($orderstat == 'processing') && ($paymethod == 'PayPal')) {

Add recipients based on user role to failed and cancelled WooCommerce emails

我只是一个虾纸丫 提交于 2019-12-09 01:52:31
问题 I want to be able to change who receives the Woocommerce email notifications based on what role the user is when ordering. For example, If the user is logged in as a Wholesale Customer then a different email will be notified. I've found how to change it when a new order is complete using the woocommerce_email_recipient_new_order hook but i can't find any hooks related to the failed or cancelled notifications. add_filter( 'woocommerce_email_recipient_new_order', 'sv_conditional_email_recipient

Add text to order summary based on a custom field value in WooCommerce

让人想犯罪 __ 提交于 2019-12-09 01:38:08
问题 I have added successfully a custom field to my WooCommerce checkout page that is a selector for different stores that the customer can choose to collect their items from. At the moment it is showing this field on the checkout page and I am using jQuery to add information below the selector and updating the shipping cost accordingly. What I need to do next is to add the field + additional info about each pickup location on the customer's order email. so for instance if the customer selects

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(

Get orders from a SQL query displayed on as a list in Woocommerce

久未见 提交于 2019-12-08 13:39:31
In woocommerce, I'm trying to create a shortcode to put in my function.php document, that displays a custom database query on a page. There's something wrong with it though and i'm not sure what. function sqlquery_shortcode($atts) { global $wpdb; $results = $wpdb->get_results(" SELECT a.order_id, a.order_item_id, a.order_item_name, b.meta_key, b.meta_value FROM 7pW9iX3L_woocommerce_order_items a JOIN 7pW9iX3L_woocommerce_order_itemmeta b ON a.order_item_id = b.order_item_id JOIN 7pW9iX3L_posts c ON a.order_id = c.ID JOIN 7pW9iX3L_postmeta d ON c.ID = d.post_id WHERE order_item_type = 'line

Get the orders IDs related to a product bought by a customer in Woocommerce

╄→尐↘猪︶ㄣ 提交于 2019-12-08 08:49:02
问题 I have the products ids as an array and I would like to get the list of order ids if the customer has purchased that product. I have the customer purchased product ids with me. Somehow, I have to get the linked order id and cancel that order if customer purchases new product. To check if a customer has purchased a product I am using the function has_bought_items() from this answer thread: Check if a customer has purchased a specific products in WooCommerce May be it can be tweaked to get the

Customize Order received page based on shipping method in WooCommerce

廉价感情. 提交于 2019-12-08 08:39:35
问题 How could I customise the order thank you page based on the order's shipping method? So for example if a customer used 'Delivery on request' option, the thank you page would display a different title. add_filter( 'the_title', 'woo_personalize_order_received_title', 10, 2 ); function woo_personalize_order_received_title( $title, $id ) { if ( is_order_received_page() && get_the_ID() === $id ) { global $wp; // Get the order. Line 9 to 17 are present in order_received() in includes/shortcodes

Adding Custom Meta Data from Products to Orders items in Woocommerce

可紊 提交于 2019-12-08 07:58:14
问题 I'm trying to get the Custom Meta data of my woocommerce products to my Order Columns in my Woocommerce Admin but this code wont work on my function.php in Wordpress Theme. // Order Get Meta for PD Number add_action('woocommerce_add_order_item_meta','adding_custom_data_in_order_items_meta', 1, 3 ); function adding_custom_data_in_order_items_meta( $post_id, $cart_item_key ) { // The corresponding Product Id for the item: $product_id = $post_id[ 'product_id' ]; //$pd_number = $post_id['_pd

How to loop product name and photos in my-orders.php page for recent orders?

纵饮孤独 提交于 2019-12-08 07:06:38
问题 I have to add product name and thumbnail to my recent orders page. I don't know how to loop them if there are more than one product in one order. (Dead image link removed) 回答1: I have Just set the loop for products names, but i haven't test it. You will have to search for thumbnails (see the link at the end). For the products loop, i have use the code from Sandeep Kumar: WooCommerce display order product name in my account foreach($order->get_items() as $item) { $product_name = $item['name'];

Set a Tracking Number link on customer email notifications in Woocommerce 3

这一生的挚爱 提交于 2019-12-08 06:51:06
问题 I've managed to get this together and now I'm trying to make the number that is being entered into the custom field (saved to the order) to be linked in the order email. Here's the code: // create the metabox add_action( 'add_meta_boxes', 'bdev_add_postnord_meta_box' ); if ( ! function_exists( 'bdev_add_postnord_meta_box' ) ) { function bdev_add_postnord_meta_box() { add_meta_box( 'postnord_field', __('PostNord Parcel ID','woocommerce'), 'bdev_add_postnord_for_tracking', 'shop_order', 'side',