Category: WooCommerce

WooCommerce: Strip the Product Page Link From the Cart Items, Showing Only Product Name

If you want to remove links from the product names in the WooCommerce cart you can use this simple filter. It returns the product name, without anything else appended. function myprefix_woocommerce_cart_item_name($name, $cart_item, $cart_item_key) { $_product = apply_filters( ‘woocommerce_cart_item_product’, $cart_item[‘data’], $cart_item, $cart_item_key ); return $_product->get_name(); } add_filter(‘woocommerce_cart_item_name’, ‘myprefix_woocommerce_cart_item_name’, 10, 3);  

WooCommerce: Show a Link to the List of Orders from the User Profile Page

This will add a “Customer Orders” link on the customer/user profile edit page.  Handy when trying to find a full history of a customer’s orders. // Show a link to the list of orders for a user function myprefix_user_orders_link(WP_User $user) { if (!ssc_is_admin()) { return; } $link = admin_url(‘edit.php?s&post_type=shop_order&_customer_user=’.$user->ID); echo ‘<tr><td colspan=”2″><a href=”‘ . $link… Read more »

WooCommerce: Add Password Confirmation Field to Registration Form

Users can register on both the account registration page and during checkout (if enabled).  This code will add a field for the user to confirm the password that they entered in the primary password field. // Validate password match on the registration page function myprefix_registration_errors_validation($reg_errors, $sanitized_user_login, $user_email) { global $woocommerce; extract( $_POST ); if (… Read more »

Prevent PO Boxes in WooCommerce Shipping Addresses

In some cases PO Boxes are not allowed when shipping certain products or when using specific carriers.  The code below disables PO Boxes for all shipping addresses.  You can add additional logic if you only need to disallow PO Boxes in certain cases. Create a function for checking if a string is a PO Box…. Read more »

WordPress: Add Login and Logout links to Menus

This snippet will add a “Log In” link for logged-out users, and a “Log Out” link for logged-in users.  In this example, it is using the theme locations “main-nav” and “footer-links” as identifiers.  Change those values to match the locations of the menu(s) that you want to use.  The user’s first name or display name… Read more »