Skip to content

Instantly share code, notes, and snippets.

View shameemreza's full-sized avatar
🦜
Talk is cheap. Check My Code, Blog and Portfolio.

Shameem Reza shameemreza

🦜
Talk is cheap. Check My Code, Blog and Portfolio.
View GitHub Profile
@shameemreza
shameemreza / remove-quantity-field-single-product.php
Created May 28, 2024 10:28
Remove the quantity field for ALL of your WooCommerce products
function custom_remove_all_quantity_fields( $return, $product ) {
return true;
}
add_filter ( 'woocommerce_is_sold_individually','custom_remove_all_quantity_fields', 10, 2 );
@shameemreza
shameemreza / remove-sidebar-storefront-theme.php
Created May 20, 2024 08:13
Remove Sidebar on Single Product Page for Storefront Theme
add_action( 'get_header', 'srdev_remove_storefront_sidebar' );
function srdev_remove_storefront_sidebar() {
if ( is_product() ) {
remove_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 );
}
}
@shameemreza
shameemreza / remove-additional-information-tab.php
Last active May 8, 2024 09:28
Remove the Additional Information tab from the WooCommerce single product pages
add_filter( 'woocommerce_product_tabs', 'remove_additional_information_tab', 98 );
function remove_additional_information_tab( $tabs ) {
// Check if the 'additional_information' tab is set and remove it
if (isset($tabs['additional_information'])) {
unset($tabs['additional_information']);
}
return $tabs;
}
@shameemreza
shameemreza / gutenberg-block-editor-support-to-woocommerce.php
Last active May 8, 2024 09:43
Add Gutenberg Editor support to WooCommerce Classic Editor
// enable gutenberg for woocommerce
function activate_gutenberg_product( $can_edit, $post_type ) {
if ( $post_type == 'product' ) {
$can_edit = true;
}
return $can_edit;
}
add_filter( 'use_block_editor_for_post_type', 'activate_gutenberg_product', 10, 2 );
// enable taxonomy fields for woocommerce with gutenberg on
@shameemreza
shameemreza / enable-customizer-menu-block-theme.php
Last active May 8, 2024 09:43
Re-enable the Customizer in a block theme
add_action( 'customize_register', '__return_true' );
@shameemreza
shameemreza / functions.php
Created April 14, 2024 05:08
Consistently display the stock status on the Single Product page in WooCommerce
add_filter( ‘woocommerce_get_availability’, ‘custom_override_get_availability’, 10, 2);
// The hook in function $availability is passed via the filter!
function custom_override_get_availability( $availability, $_product ) {
if ( $_product->is_in_stock() ) $availability[‘availability’] = __(‘In stock’, ‘woodmart’);
return $availability;
}
@shameemreza
shameemreza / functions.php
Last active April 14, 2024 05:08
Add a custom text to your WooCommerce Price suffix - Price + Free shipping (Product Archive and Product Single)
add_filter( 'woocommerce_get_price_html', 'custom_price_html', 100, 2 );
function custom_price_html( $price, $product ){
$price .= ' + free shipping';
return $price;
}
@shameemreza
shameemreza / funcstion.php
Created March 14, 2024 10:49
WooCommerce - Change product order of displayed upsells on product pages
add_filter( 'woocommerce_upsell_display_args', 'change_upsell_order', 20 );
function change_upsell_order( $args ) {
$args['orderby'] = 'date';
$args['order'] = 'DESC'; // set ASC for oldest to newest
return $args;
}
@shameemreza
shameemreza / functions.php
Created February 25, 2024 14:58
Change Page Title for Woocommerce Shop Page
function shop_title( $title ) {
if ( is_shop() && isset( $title['title'] ) ) {
$title['title'] = apply_filters( 'the_title', get_the_title( get_option( 'woocommerce_shop_page_id' ) ) );
}
return $title;
}
add_filter( 'document_title_parts', 'shop_title' );
@shameemreza
shameemreza / uncheck-follow-up-replies-via-email-checbox.js
Created November 9, 2023 17:02
Uncheck follow-up replies via email checbox on WordPress.org Forum
// ==UserScript==
// @name Uncheck follow-up replies via email checbox
// @namespace http://tampermonkey.net/
// @version 0.1
// @description When you're on the WordPress.org forum, the system automatically selects the checkbox to receive follow-up replies via email. However, you don't have to subscribe to all threads as a support representative. This script will automatically uncheck this box.
// @author Shameem Reza
// @match https://wordpress.org/support/topic/*
// @grant none
// ==/UserScript==