Automatically check the option “Enable stock management at product level” on product creation

To set default values of a new post, you can try this code : $postType = “product”; add_action(“save_post_” . $postType, function ($post_ID, \WP_Post $post, $update) { if (!$update) { // default values for new products update_post_meta($post->ID, “_manage_stock”, “yes”); update_post_meta($post->ID, “_stock”, 1); return; } // here, operations for updated products }, 10, 3);

How does WordPress redirect to WooCommerce shop page? [closed]

You could add a rewrite rule to improve the appearance of the URL while maintaining the same functionality: As an example: add_action(‘init’, ‘custom_shop_param’); function custom_shop_param() { add_rewrite_tag(‘%param%’,'([^&]+)’); add_rewrite_rule(‘^shop/([^/]+)/?$’,’index.php?page=shop&param=$matches[1]’,’top’); } When you visit http://site/wp/shop/{somevalue} the value that proceeds the /shop/ portion of the URL will be matched and stored in the query var param which is … Read more

WooCommerce – Customer Order History Pagination

I have added pagination in order history page and it is working. Replace below code above loop $my_orders_columns = apply_filters( ‘woocommerce_my_account_my_orders_columns’, array( ‘order-number’ => __( ‘ID’, ‘woocommerce’ ), ‘order-date’ => __( ‘Date’, ‘woocommerce’ ), ‘order-total’ => __( ‘Packages’, ‘woocommerce’ ), ‘order-total’ => __( ‘Price’, ‘woocommerce’ ), ‘order-status’ => __( ‘Status’, ‘woocommerce’ ), ‘order-actions’ => ‘ ’, … Read more