Category: eCommerce
Categorias pai a negrito e lembrete para nao esquecer de prencher certos campos ao adicionar um produto
/** * Validação completa para produtos WooCommerce * Verifica preço, categoria, referência (SKU) e peso */ function validar_produto_woocommerce_completo($post_id) { // Verifica se é um produto if (get_post_type($post_id) !== ‘product’) { return; } // Verifica se está salvando o produto (não…Continue reading
Add Wholesale Order Form Favourites Button Functionality To WooCommerce Single Product Pages
/** * Output scripts and styles for the favourites button in the head. */ function wwof_output_favourites_scripts() { // Only load on single product pages. if ( ! is_product() ) { return; } // Get current user ID. $user_id = get_current_user_id();…Continue reading
WooCommerce Delivery Address Popup – Sync Address in Header & Checkout
/* * Use the shortcode [deliver_to_address] wherever you want the address to appear (e.g., header, sidebar, pages). * Author: Muhammad Mubeen A (wp_expert28) * */ // Shortcode to display “Deliver to:” widget with address edit popup add_shortcode(‘deliver_to_address’, function () {…Continue reading
Remove field checkout WooCommerce
/** Remove all possible fields **/ function mrj_remove_checkout_fields( $fields ) { // Billing fields unset( $fields[‘billing’][‘billing_state’] ); unset( $fields[‘billing’][‘billing_company’] ); // Shipping fields unset( $fields[‘shipping’][‘shipping_state’] ); unset( $fields[‘shipping’][‘shipping_company’] ); return $fields; } add_filter( ‘woocommerce_checkout_fields’, ‘mrj_remove_checkout_fields’ );Continue reading
Restrict payment methods based on cart total
add_filter(‘woocommerce_available_payment_gateways’, ‘limit_payment_gateway_based_on_cart_total’); function limit_payment_gateway_based_on_cart_total($available_gateways) { if (is_admin() || !is_checkout()) { return $available_gateways; } // Get total cart $cart_total = WC()->cart->get_total(‘edit’); // Total cart without formattation // Set limit $limit = 1000; // Limit in local currency // If the total…Continue reading
Change name On Hold status WooCommerce
add_filter( ‘wc_order_statuses’, ‘ts_rename_order_status_msg’, 20, 1 ); function ts_rename_order_status_msg( $order_statuses ) { $order_statuses[‘wc-on-hold’] = _x( ‘In attesa di pagamento’, ‘Order status’, ‘woocommerce’ ); return $order_statuses; }Continue reading
Hide uncategorized from widget shop
add_filter( ‘get_terms’, ‘ts_get_subcategory_terms’, 10, 3 ); function ts_get_subcategory_terms( $terms, $taxonomies, $args ) { $new_terms = array(); // if it is a product category and on the shop page if ( in_array( ‘product_cat’, $taxonomies ) && ! is_admin() &&is_shop() ) {…Continue reading
Block specific coupons during set hours
/** * Block specific coupons during set hours (1:00 PM – 3:00 PM) */ function block_coupon_during_specific_hours($valid, $coupon) { if (!$valid) return $valid; // List of coupon codes to block during specific hours $blocked_coupons = array( ‘YOUR_COUPON_CODE_HERE’, // Replace with your…Continue reading
How to Display Store Credits Earned in WooCommerce New Order Emails
// Add store credit info to WooCommerce new order email notification // Store credits as coupon (before tax). $coupons = $order->get_coupons(); foreach ( $coupons as $coupon ) { if ( strtolower( $coupon->get_code() ) === ‘store credit’ ) { $sc_amount =…Continue reading