Category : orders

I write function: add_action( ‘woocommerce_order_status_completed’, ‘order_completed’); function order_completed($order_id) { $user_id = $order->get_user_id(); // or $order->get_customer_id(); $order = wc_get_order( $order_id ); $items = $order->get_items(); foreach ( $items as $item ) { $product_name = $item->get_name(); } switch ($product_name) { case ‘FREE’: update_user_meta($user_id, ‘ads-available’, get_user_meta( $user_id, ‘ads-available’, true ) +1 ); break; case ‘VIP’: update_user_meta($user_id, ‘ads-available’, get_user_meta( $user_id, ..

Read more

Is it possible to get only latest product of woocommerce order? I know that is possible for notes as example: // Get last order note $latest_notes = wc_get_order_notes( array( ‘order_id’ => $order->get_id(), ‘limit’ => 1, ‘orderby’ => ‘date_created_gmt’, ) ); $latest_note = current( $latest_notes ); Can I make something similar for products inside order? Source: ..

Read more

Is it possible to get only latest product of woocommerce order? I know that is possible for notes as example: // Get last order note $latest_notes = wc_get_order_notes( array( ‘order_id’ => $order->get_id(), ‘limit’ => 1, ‘orderby’ => ‘date_created_gmt’, ) ); $latest_note = current( $latest_notes ); Can I make something similar for products inside order? Source: ..

Read more

I have made custom order type to show particular orders, here is code : wc_register_order_type( ‘wallet_shop_order’, apply_filters( ‘woocommerce_register_post_type_wallet_shop_order’, array( ‘labels’ => array( ‘name’ => __( ‘Wallet Recharge Orders’, ‘wallet-payment-gateway’ ), ‘singular_name’ => __( ‘Wallet Recharge Order’, ‘wallet-payment-gateway’ ), ‘all_items’ => __( ‘Wallet Recharge Orders’, ‘wallet-payment-gateway’ ), ‘add_new_item’ => __( ‘Add New Order’, ‘wallet-payment-gateway’ ), ‘add_new’ ..

Read more

I am using a plugin to send custom referral codes in the email orders but now I found that every order email has the code inserted: function gens_raf_customer_email( $order, $sent_to_admin, $plain_text ) { $user_id = ( version_compare( WC_VERSION, ‘2.7’, ‘<‘ ) ) ? $order->customer_user : $order->get_customer_id(); if( ! empty( $user_id ) && ( get_user_meta($user_id, "gens_referral_id", ..

Read more

I am modifying my shop to show custom fields on WooCommerce order page after the order has been made. My code is inserted into default /themes/mytheme/woocommerce/order/order-details-item.php. This is the part that reads the field: $per_unit_or_square = get_field(‘pricem2_or_priceunit_’, $product->get_id()); if (!empty($per_unit_or_square)) { if ($per_unit_or_square == ‘unit’) { $pricingtype_order_received = ‘<span class="pricingtype_order_received">’.__(‘&nbsp;unit&nbsp;’, ‘mbb’).'</span>’; } elseif ($per_unit_or_square == ..

Read more