https://www.grahamethomson.com/2018/05/10/change-choose-an-option-in-woocommerce/
Thursday, October 29, 2020
Woocommerce: Only add the order item image when the product exists in the Woocommerce Order view
https://www.thinbug.com/q/51848205
// Display the product thumbnail in order view pages
add_filter( 'woocommerce_order_item_name', 'display_product_image_in_order_item', 20, 3 );
function display_product_image_in_order_item( $item_name, $item, $is_visible ) {
// Targeting view order pages only
if( is_wc_endpoint_url( 'view-order' ) ) {
// Get the WC_Product object (from order item)
$product = $item->get_product();
// Testing if the product exist in Woocommerce <== UPDATE
if( $product && is_object( $product ) ) {
// Get the product thumbnail (from product object)
$thumbnail = $product->get_image(array( 36, 36));
// Avoiding empty thumbnail (updated)
if( $product->get_image_id() > 0 )
$item_name = '<div class="item-thumbnail">' . $thumbnail . '</div>' . $item_name;
} else {
// When product doesn't exist, we get the name from the order item (with no thumbnail)
$item_name = $item->get_name();
}
}
return $item_name;
}
Woocommerce: Cart Page more customisation (Future Requirements)
https://css-tricks.com/how-to-customize-the-woocommerce-cart-page-on-a-wordpress-site/
Sunday, October 25, 2020
Woocommerce: My Account Page --> Initial login redirects to orders page like Walmart
// Redirect initial login straight away to orders page like Walmart
//
add_action('template_redirect', 'redirect_to_orders_from_dashboard' );
function redirect_to_orders_from_dashboard(){
if( is_account_page() && empty( WC()->query->get_current_endpoint() ) ){
wp_safe_redirect( wc_get_account_endpoint_url( 'orders' ) );
exit;
}
}
Woocommerce: Disable Default Shop Page
/**
* DISABLE DEFAULT SHOP PAGE
*/
function woocommerce_disable_shop_page() {
global $post;
if (is_shop()):
global $wp_query;
$wp_query->set_404();
status_header(404);
endif;
}
add_action( 'wp', 'woocommerce_disable_shop_page' );
Friday, October 23, 2020
Woocommerce: Cart Summary - which "Return to Shop" to use?
Shows nothing....
// Hide "Return to Shop" button when all items are removed @ Cart Page
remove_action( 'woocommerce_cart_is_empty', 'wc_empty_cart_message', 10); //remove the default message
add_action( 'woocommerce_cart_is_empty', 'custom_empty_cart_message', 10); //add custom designed
function custom_empty_cart_message() {
echo "Oops your cart is lonely...";
add_action( 'woocommerce_return_to_shop', 'return_to_shop', 10); //remove return to shop button
//$_SERVER['cart'];
}
Shows both messages with custom messaging....
// Hide "Return to Shop" button when all items are removed @ Cart Page
remove_action( 'woocommerce_cart_is_empty', 'wc_empty_cart_message', 10 );
add_action( 'woocommerce_cart_is_empty', 'custom_empty_cart_message', 10 );
function custom_empty_cart_message() {
//$html = '<div class="col-12 offset-md-1 col-md-10"><p class="cart-empty">';
$html .= wp_kses_post( apply_filters( 'wc_empty_cart_message', __( 'Your cart is currently empty.', 'woocommerce' ) ) );
echo $html . '</p></div>';
}
Woocommerce: Cart Summary Page Customisation
/**
* CART SUMMARY PAGE CUSTOMISATION
*/
// Hide Other shipping rates when free shipping is available @ Cart & Checkout Page
add_filter( 'woocommerce_package_rates', 'my_hide_shipping_when_free_is_available' );
function my_hide_shipping_when_free_is_available( $rates ) {
$free = array();
foreach( $rates as $rate_id => $rate ) {
if( 'free_shipping' === $rate->method_id ) {
$free[ $rate_id ] = $rate;
break;
}
}
return ! empty( $free ) ? $free : $rates;
}
// Changes the redirect URL for the Return To Shop button in the cart (return string)
function wc_empty_cart_redirect_url() {
return 'http://olamiie.com/product-category/shop/';
}
add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' );
// Hide "Return to Shop" button when all items are removed @ Cart Page
remove_action( 'woocommerce_cart_is_empty', 'wc_empty_cart_message', 10); //remove the default message
add_action( 'woocommerce_cart_is_empty', 'custom_empty_cart_message', 10); //add custom designed
function custom_empty_cart_message() {
echo "Oops your cart is lonely...";
add_action( 'woocommerce_return_to_shop', 'return_to_shop', 10); //remove return to shop button
//$_SERVER['cart'];
}
Woocommerce: My Account Page Customisation
/**
* My ACCOUNT PAGE CUSTOMISATION
*/
//Merge Two "My Account" Tabs @ WooCommerce Account
// Remove Downloads Tab (downloads in this case)
add_filter( 'woocommerce_account_menu_items', 'remove_downloads_my_account', 999 );
function remove_downloads_my_account( $items ) {
unset($items['downloads']);
return $items;
}
// 1. First, hide the tab that needs to be merged/moved (edit-address in this case)
add_filter( 'woocommerce_account_menu_items', 'remove_address_my_account', 999 );
function remove_address_my_account( $items ) {
unset($items['edit-address']);
return $items;
}
// 1. First, hide the tab that needs to be merged/moved (payment-methods in this case)
add_filter( 'woocommerce_account_menu_items', 'remove_payment_my_account', 999 );
function remove_payment_my_account( $items ) {
unset($items['payment-methods']);
return $items;
}
// 2. Second, print the ex tab content into an existing tab (edit-account in this case)
add_action( 'woocommerce_account_edit-account_endpoint', 'woocommerce_account_edit_address' );
//add_action( 'woocommerce_account_edit-account_endpoint', 'woocommerce_account_payment_methods' );
/**
* Register new endpoints to use inside My Account page.
*/
add_action( 'init', 'my_account_new_endpoints' );
function my_account_new_endpoints() {
add_rewrite_endpoint( 'warranty-requests', EP_ROOT | EP_PAGES );
}
/**
* Get new endpoint content
*/
// Warranty
add_action( 'woocommerce_warranty_requests_endpoint', 'warranty_requests_endpoint_content' );
function warranty_requests_endpoint_content() {
get_template_part('warranty-requests');
}
// Rename, re-order my account menu items
function reorder_my_account_menu() {
$neworder = array(
'dashboard' => __( 'Dashboard', 'woocommerce' ),
'orders' => __( 'Orders', 'woocommerce' ),
'wishlist' => __( 'Wishlist', 'woocommerce' ),
//‘edit-address' => __( 'Addresses', 'woocommerce' ),
'edit-account' => __( 'Account Details', 'woocommerce' ),
'warranty-requests' => __( 'Limited Warranty', 'woocommerce' ),
'customer-logout' => __( 'Logout', 'woocommerce' ),
);
return $neworder;
}
add_filter ( 'woocommerce_account_menu_items', 'reorder_my_account_menu' );
// Display the product thumbnail in order view pages like Uniqlo
add_filter( 'woocommerce_order_item_name', 'display_product_image_in_order_item', 20, 3 );
function display_product_image_in_order_item( $item_name, $item, $is_visible ) {
// Targeting view order pages only
if( is_wc_endpoint_url( 'view-order' ) ) {
// Get the WC_Product object (from order item)
$product = $item->get_product();
// Testing if the product exist in Woocommerce <== UPDATE
if( $product && is_object( $product ) ) {
// Get the product thumbnail (from product object)
$thumbnail = $product->get_image(array( 36, 36));
// Avoiding empty thumbnail (updated)
if( $product->get_image_id() > 0 )
$item_name = '<div class="item-thumbnail">' . $thumbnail . '</div>' . $item_name;
} else {
// When product doesn't exist, we get the name from the order item (with no thumbnail)
$item_name = $item->get_name();
}
}
return $item_name;
}
Woocommerce: Checkout Page Customisation
/**
* CHECKOUT PAGE CUSTOMISATION
*/
// Remove Coupon form at checkout page
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
// Show product thumbnail on checkout page.
// @see {templates|woocommerce}/checkout/review-order.php
add_filter( 'woocommerce_cart_item_name', 'jfs_checkout_show_product_thumbnail', 10, 2 );
function jfs_checkout_show_product_thumbnail( $name, $cart_item ) {
if ( ! is_checkout() ) return $name;
$thumbnail = '<span class="product-name__thumbnail" style="float: left; padding-right: 15px">' . get_the_post_thumbnail( $cart_item['product_id'], array( 60, 120 ) ) . '</span>';
return $thumbnail . '<span class="product-name__text">' . $name . '</span>';
}
Woocommerce: Temporarily Disable Shop Page - While on Vacation
https://passwordprotectwp.com/disable-woocommerce-shop-page/
/** * @snippet WooCommerce Holiday/Pause Mode * @how-to Get CustomizeWoo.com FREE * @sourcecode https://businessbloomer.com/?p=20862 * @author Rodolfo Melogli * @testedwith WooCommerce 3.5.1 * @donate $9 https://businessbloomer.com/bloomer-armada/ */ // Trigger Holiday Mode add_action ('init', 'bbloomer_woocommerce_holiday_mode'); // Disable Cart, Checkout, Add Cart function bbloomer_woocommerce_holiday_mode() { remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 ); remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 ); add_action( 'woocommerce_before_main_content', 'bbloomer_wc_shop_disabled', 5 ); add_action( 'woocommerce_before_cart', 'bbloomer_wc_shop_disabled', 5 ); add_action( 'woocommerce_before_checkout_form', 'bbloomer_wc_shop_disabled', 5 ); } // Show Holiday Notice function bbloomer_wc_shop_disabled() { wc_print_notice( 'Our Online Shop is Closed Today :)', 'error'); }
Thursday, October 22, 2020
Woocommerce: My Additional CSS
/** MY ACCOUNT PAGE --> ORDERS BUTTONS **/ a.view { margin: 3px; } /*Remove Package tracking buttons*/ a.woocommerce-button.button.ast_track { display: none; } /*Remove Warranty Request buttons*/ a.woocommerce-button.button.warranty_request { display: none; } /** MY ACCOUNT PAGE --> Individual Order **/ /*Underline tracking number for clicking to see the tracking information page */ td.tracking-number { text-decoration: underline !important; } /** WISHLIST HEART ICON STYLING **/ i.fa-heart-o { color: darksalmon; /*font-size: 0.3em;*/ } i.fa-heart { color: darksalmon; /*font-size: 0.3em;*/ } /* Hide the old red "x" & hover */ .remove.remove_from_wishlist { visibility:hidden!important; /*hide everything*/ width:auto!important; /*make sure to have the need width for "remove" */ } /* Add a Fontawesome icon instead for "remove from cart" icon with garbage icon */ .remove.remove_from_wishlist:before { visibility:visible; font-family: FontAwesome; font-size: 17px; color: dimgray; content: "\f1f8"; float: left; text-indent: 0; } } /** SINGLE PRODUCT PAGE **/ /** Reviews Styling **/ h2.woocommerce-Reviews-title{ font-family: Poppins; font-weight: 200; font-size: 12px; line-height: 1.5; } /** Hide QTY text box on Single Product Page ONLY**/ .single-product .quantity input[type="number"] { display: none !important; } /** CART PAGE STYLING FOR MOBILE **/ /** MyStyle: Show thumbnail in cart larger than default 32px **/ .woocommerce-cart table.cart img { width: auto; min-width: 32px; max-width: 100px; } @media(max-width:768px) { /** Show thumbnail row in cart on mobile **/ .woocommerce-page table.cart .product-thumbnail { display: inline-block !important; } /** hide colon above thumbnail for mobile **/ .woocommerce-page table.cart .product-thumbnail:before { display: none; } } /** CART PAGE STYLING **/ /**Remove all internal borders**/ /*.woocommerce-cart .woocommerce table.shop_table{ border: 1px solid #54595f;}*/ .woocommerce-cart table.shop_table thead{ border: none; color: none; text-align: right; } .woocommerce-cart table.shop_table td{ border: none; } .woocommerce-cart .cart-collaterals .cart_totals tr th{ border: none; } .woocommerce-cart .cart-collaterals .cart_totals tr td{ border: none; } /* Hide the old red "x" & hover */ .woocommerce-cart a.remove { visibility:hidden!important; /*hide everything*/ width:auto!important; /*make sure to have the need width for "remove" */ } /* Add a Fontawesome icon instead for "remove from cart" icon with garbage icon */ .woocommerce-cart a.remove:before { visibility:visible; font-family: FontAwesome; font-size: 17px; color: dimgray; content: "\f1f8"; float: left; text-indent: 0; } } /*Update cart button*/ .woocommerce-cart table.cart td.actions .button, .woocommerce-checkout table.cart td.actions .button, #add_payment_method table.cart td.actions .button { float: right; margin: 30px; } /** CHECKOUT PAGE STYLING **/ /**Remove all internal borders**/ woocommerce #order_review table.shop_table th{ border: none; --text-align: left; } .woocommerce #order_review table.shop_table td{ border: none; --text-align: left; } .woocommerce #order_review table.shop_table th{ border: none; --text-align: left; } /**Always show checkout coupon, reduce clicking**/ .checkout_coupon { display: block !important; } .woocommerce-info { display:none; }
Woocommerce: Single Product Page Customisation
/**
* SINGLE PRODUCT PAGE CUSTOMISATION
*/
// Remove Categories @ Single Products
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
// Hide "in stock" @ Single Products
function my_wc_hide_in_stock_message( $html, $text, $product ) {
$availability = $product->get_availability();
if ( isset( $availability['class'] ) && 'in-stock' === $availability['class'] ) {
return '';
}
return $html;
}
add_filter( 'woocommerce_stock_html', 'my_wc_hide_in_stock_message', 10, 3 );
// Hide "Additional Information tab" @ Single Products
add_filter( 'woocommerce_product_tabs', 'bbloomer_remove_product_tabs', 9999 );
function bbloomer_remove_product_tabs( $tabs ) {
unset( $tabs['additional_information'] );
return $tabs;
}
// Hide "xx product has been added to your cart" @ Single Product Page
add_filter( 'wc_add_to_cart_message_html', '__return_false' );
// Change location of price to above "Add to Cart" button
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 20 );
Woocommerce: My Account Page Customisation
/**
* My ACCOUNT PAGE CUSTOMISATION
*/
/**
* @snippet Merge Two "My Account" Tabs @ WooCommerce Account
* @how-to Get CustomizeWoo.com FREE
* @source https://businessbloomer.com/?p=73601
* @author Rodolfo Melogli
* @compatible Woo 3.5.3
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/
// -------------------------------
// Remove Downloads Tab (downloads in this case)
add_filter( 'woocommerce_account_menu_items', 'remove_downloads_my_account', 999 );
function remove_downloads_my_account( $items ) {
unset($items['downloads']);
return $items;
}
// -------------------------------
// 1. First, hide the tab that needs to be merged/moved (edit-address in this case)
add_filter( 'woocommerce_account_menu_items', 'remove_address_my_account', 999 );
function remove_address_my_account( $items ) {
unset($items['edit-address']);
return $items;
}
// -------------------------------
// 1. First, hide the tab that needs to be merged/moved (payment-methods in this case)
add_filter( 'woocommerce_account_menu_items', 'remove_payment_my_account', 999 );
function remove_payment_my_account( $items ) {
unset($items['payment-methods']);
return $items;
}
// -------------------------------
// 2. Second, print the ex tab content into an existing tab (edit-account in this case)
add_action( 'woocommerce_account_edit-account_endpoint', 'woocommerce_account_edit_address' );
//add_action( 'woocommerce_account_edit-account_endpoint', 'woocommerce_account_payment_methods' );
// -------------------------------
// Redirect initial login straight away to orders page like Walmart
//
add_action('template_redirect', 'redirect_to_orders_from_dashboard' );
function redirect_to_orders_from_dashboard(){
if( is_account_page() && empty( WC()->query->get_current_endpoint() ) ){
wp_safe_redirect( wc_get_account_endpoint_url( 'orders' ) );
exit;
}
}
// Display the product thumbnail in order view pages
add_filter( 'woocommerce_order_item_name', 'display_product_image_in_order_item', 20, 3 );
function display_product_image_in_order_item( $item_name, $item, $is_visible ) {
// Targeting view order pages only
if( is_wc_endpoint_url( 'view-order' ) ) {
// Get the WC_Product object (from order item)
$product = $item->get_product();
// Testing if the product exist in Woocommerce <== UPDATE
if( $product && is_object( $product ) ) {
// Get the product thumbnail (from product object)
$thumbnail = $product->get_image(array( 36, 36));
// Avoiding empty thumbnail (updated)
if( $product->get_image_id() > 0 )
$item_name = '<div class="item-thumbnail">' . $thumbnail . '</div>' . $item_name;
} else {
// When product doesn't exist, we get the name from the order item (with no thumbnail)
$item_name = $item->get_name();
}
}
return $item_name;
}
Wednesday, October 21, 2020
Woocommerce: My Account Page -> Remove "Payment Method" Tab
// -------------------------------
// 1. First, hide the tab that needs to be merged/moved (payment-methods in this case)
add_filter( 'woocommerce_account_menu_items', 'remove_payment_my_account', 999 );
function remove_payment_my_account( $items ) {
unset($items['payment-methods']);
return $items;
}
I did not remove payment tab because I didn't know where to put it later. So I left it as it is.
Woocommerce: My Account Page -> Remove "Dashboard" Tab
Redirect the Dashboard page to Orders Page like Walmart
// -------------------------------
// Redirect initial login straight away to orders page like Walmart
//
add_action('template_redirect', 'redirect_to_orders_from_dashboard' );
function redirect_to_orders_from_dashboard(){
if( is_account_page() && empty( WC()->query->get_current_endpoint() ) ){
wp_safe_redirect( wc_get_account_endpoint_url( 'orders' ) );
exit;
}
}
This works but unable to use with with RMA plugin as it looks for dashboard to load.
Saturday, October 17, 2020
Wednesday, October 7, 2020
How To Make & Braid Challah
Follow this recipe: https://toriavey.com/how-to/challah-bread-part-1-the-blessing-and-the-dough/
I will test all the different braiding listed here: https://toriavey.com/how-to/challah-bread-part-2-how-to-braid-challah/
Tuesday, October 6, 2020
Printing on Fabric
I have such a hard time finding customised iron-on transfer in my budget. I decided to... stamp my logo on!
Here's my research.
What ink.
http://www.crafttestdummies.com/comparison-of-stamp-pad-inks-on-fabric/
https://www.thestampmaker.com/tips-and-tricks-for-fabric-stamping.aspx