Add custom variable to cart content [closed]

I had to do something similar a while ago, this is what was working for me: In the example, the custom input name is “test_field” inside the add to cart form, and this way when you dump the cart_contents, you can see the value somewhere at the end //Store the custom field add_filter( ‘woocommerce_add_cart_item_data’, ‘add_cart_item_custom_data_vase’, … Read more

Display order items names in WooCommerce admin orders list [closed]

Never overwrite core files! for many reasons. Note that an order can have many items (products). On orders admin list, the following will add item(s) (product(s)) names, to order status column: add_action( ‘manage_shop_order_posts_custom_column’ , ‘custom_orders_list_column_content’, 20, 2 ); function custom_orders_list_column_content( $column, $post_id ) { global $the_order, $post; if ( ‘order_status’ === $column ) { $products_names … Read more

How to disable Woocommerce password recovery and use the default WordPress password reset page?

I found the solution in WP forum. Here it is: To remove the WooCommerce redirect for the “Lost Password” link, you’ll want to remove the “Lost Password” endpoint setting as found under **WooCommerce > Settings > Advanced > Account endpoints**. By simply leaving that blank, the user will be forced to use the default WordPress … Read more

add_filter to modify woocommerce_cart_item_name hyperlink

The key is to pass arguments to the callback function. Try this: /* Function that returns custom product hyperlink */ function wc_cart_item_name_hyperlink( $link_text, $product_data ) { $title = get_the_title($product_data[‘product_id’]); return sprintf( ‘<a href=”https://wordpress.stackexchange.com/questions/216353/%s”>%s </a>’,’example.com/mypage/’,$title ); } /* Filter to override cart_item_name */ add_filter( ‘woocommerce_cart_item_name’, ‘wc_cart_item_name_hyperlink’, 10, 2 ); The $product_data parameter is an array that … Read more

Move payment options at checkout in WooCommerce [closed]

You can customize the checkout page using hooks. To remove the payment options add the following code to your (child)theme’s functions.php: remove_action( ‘woocommerce_checkout_order_review’, ‘woocommerce_checkout_payment’, 20 ); To add it after the order notes use this hook: add_action( ‘woocommerce_after_order_notes’, ‘woocommerce_checkout_payment’, 20 );

Correct function to get the user’s latest Woocommerce Subscription?

use this code $users_subscriptions = wcs_get_users_subscriptions($user_id); retrieve the data using foreach foreach ($users_subscriptions as $subscription){ if ($subscription->has_status(array(‘active’))) { echo $subscription->get_id(); } } There is some function to access subscription data. like get_id(),get_date(‘end’) (to get last date of subscription ). I hope its help you well.