This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @snippet Adding the User Avatar in My Account Page | |
* @author Nicola Mustone | |
* @author_url https://nicolamustone.blog/2014/12/26/add-the-customer-avatar-in-my-account-page-in-storefront/ | |
* @tested-up-to WooCommerce 8.4.X | |
*/ | |
function nm_myaccount_customer_avatar() { | |
$current_user = wp_get_current_user(); | |
echo '<div class="myaccount_avatar">' . get_avatar( $current_user->user_email, 128, '', $current_user->display_name ) . '</div>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.myaccount_avatar { | |
border-right: 1px solid rgba(0, 0, 0, 0.1); | |
float: left; | |
padding-right: 10px; | |
margin-right: 10px; | |
width: 139px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @template Sell to Specific States/Provinces/Regions with WooCommerce | |
* @author Nicola Mustone | |
* @author_url https://nicolamustone.blog/2014/12/08/sell-in-specific-states-with-woocommerce/ | |
* @tested-up-to WooCommerce 8.4.X | |
*/ | |
function wc_sell_only_states( $states ) { | |
$states['US'] = array( | |
'CA' => __( 'California', 'woocommerce' ), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @template Custom Product Vendor Catalog Page | |
* @author Nicola Mustone | |
* @author_url https://nicolamustone.blog/2014/10/15/show-custom-template-vendor-shop-pages/ | |
* @tested-up-to WooCommerce 8.4.X | |
*/ | |
defined( 'ABSPATH' ) || exit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @snippet Get Related Products by Attributes | |
* @author Nicola Mustone | |
* @author_url https://nicolamustone.blog/2023/12/21/improve-woocommerce-related-products-recommendations/ | |
* @tested-up-to WooCommerce 8.4.X | |
*/ | |
add_filter( 'woocommerce_related_products', 'nm_realted_products_by_attributes', 10, 3 ); | |
function nm_realted_products_by_attributes( $related_posts, $product_id, $args ) { | |
$product = wc_get_product( $product_id ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'woocommerce_single_product_summary', 'custom_pdf_catalog_download_button' ); | |
function custom_pdf_catalog_download_button() { | |
return do_shortcode( '[wc-store-catalog-pdf]' ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
li.product .short-description { | |
text-align: left; | |
color: #333333; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'woocommerce_after_shop_loop_item', 'woo_show_excerpt_shop_page', 6 ); | |
function woo_show_excerpt_shop_page() { | |
global $product; | |
echo '<p class="short-description">' . $product->post->post_excerpt . '</p>'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class WC_Custom_My_Account_Tabs extends WC_Query { | |
/** | |
* Adds main filters and actions and inits the endpoints. | |
*/ | |
public function __construct() { | |
add_action( 'init', array( $this, 'add_endpoints' ) ); | |
if ( ! is_admin() ) { | |
add_filter( 'query_vars', array( $this, 'add_query_vars' ), 0 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_continue_shopping_redirect', 'custom_continue_shopping_redirect' ); | |
function custom_continue_shopping_redirect( $default ) { | |
// Example condition 1: Redirect to Home | |
if ( /* your condition for Home */ ) { | |
return home_url(); // Redirects to the Home page | |
} | |
// Example condition 2: Redirect to Shop | |
if ( /* your condition for Shop */ ) { |
NewerOlder