This file contains hidden or 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_cart_coupon', 'woocommerce_empty_cart_button' ); | |
function woocommerce_empty_cart_button() { | |
echo '<a href="' . esc_url( add_query_arg( 'empty_cart', 'yes' ) ) . '" class="button" title="' . esc_attr( 'Empty Cart', 'woocommerce' ) . '">' . esc_html( 'Empty Cart', 'woocommerce' ) . '</a>'; | |
} |
This file contains hidden or 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_order_details_after_order_table', 'post_sale_cross_sell' ); | |
function post_sale_cross_sell( $order ) { | |
$cross_sells = array(); | |
$in_order = array(); | |
foreach ( $order->get_items() as $item ) { | |
$product_id = $order->get_item( $item )->get_product_id(); | |
$product = wc_get_product( $product_id ); | |
$cross_sells = array_merge( $product->get_cross_sell_ids(), $cross_sells ); |
This file contains hidden or 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_localisation_address_formats', 'change_us_address_format' ); | |
function change_us_address_format( $formats ) { | |
$formats['US'] = "{name}\n{company}\n{address_1}\n{address_2}\n{city}, {state} {postcode}\n{country}"; | |
return $formats; | |
} |
This file contains hidden or 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 hidden or 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 hidden or 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
/** | |
* Change the subscription thank you message after purchase | |
* | |
* @param int $order_id | |
* @return string | |
*/ | |
function custom_subscription_thank_you( $order_id ){ | |
if( WC_Subscriptions_Order::order_contains_subscription( $order_id ) ) { | |
$thank_you_message = sprintf( __( '%sThank you for purchasign our subscription! Visit %syour account%s page to know its status.%s', 'woocommerce-subscriptions' ), '<p>', '<a href="' . get_permalink( wc_get_page_id( 'myaccount' ) ) . '">', '</a>','</p>' ); |
This file contains hidden or 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
public function is_new_post( $post ) { | |
$process_old_posts = get_option( 'wp_discord_post_process_old_posts' ); | |
$post_date = strtotime( $post->post_date ); | |
var_dump( | |
$post_date < current_time( 'timestamp' ), | |
'yes' === $process_old_posts, | |
'yes' !== get_post_meta( $post->ID, '_wp_discord_post_published', true ) | |
); |
This file contains hidden or 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 | |
// Delete Expired Coupons that have an expiration date set and are not from AutomateWoo | |
add_action('delete_expired_coupons_hook', 'delete_expired_coupons_action'); | |
function delete_expired_coupons_action() { | |
$query_args = [ | |
'fields' => 'ids', | |
'post_type' => 'shop_coupon', | |
'post_status' => 'any', | |
'posts_per_page' => -1, | |
'orderby' => 'date', |
This file contains hidden or 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
add_filter( 'woocommerce_get_script_data', 'my_strength_meter_custom_strings', 10, 2 ); | |
function my_strength_meter_custom_strings( $data, $handle ) { | |
if ( 'wc-password-strength-meter' === $handle ) { | |
$data_new = array( | |
'i18n_password_error' => esc_attr__( 'Come on, enter a stronger password.', 'theme-domain' ), | |
'i18n_password_hint' => esc_attr__( 'The password should be at least seven characters long.', 'theme-domain' ) | |
); | |
$data = array_merge( $data, $data_new ); | |
} |
This file contains hidden or 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
add_action( 'init', 'custom_init', 999 ); | |
function custom_init() { | |
$order = wc_get_order( 123 ); | |
$order->set_payment_method_title( 'Credit Card' ); | |
} |