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 / 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==
@shameemreza
shameemreza / fix-mixed-content.htaccess
Created June 9, 2023 15:13
Fix Mixed Content in WordPress
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/ [NC]
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)(\.jpg|\.jpeg|\.png|\.gif|\.js|\.css)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
add_filter( 'woocommerce_allow_marketplace_suggestions', '__return_false' );
@shameemreza
shameemreza / removing-options-from-the-product-data-panel-in-woocommerce.php
Created April 5, 2023 07:15
Add or remove the PHP comment (//) before a tab that you need to remove or show. Detailed guide: https://shameem.me/removing-options-from-the-product-data-panel-in-woocommerce
// Remove options from the Product Data Panel in WooCommerce
function remove_product_data_tabs( $tabs ) {
//unset( $tabs['general'] );
unset( $tabs['inventory'] );
unset( $tabs['shipping'] );
unset( $tabs['linked_product'] );
//unset( $tabs['attribute'] );
//unset( $tabs['variations'] );
//unset( $tabs['advanced'] );
return $tabs;
@shameemreza
shameemreza / forwardRef-anduseRef-2.jsx
Created April 2, 2023 13:42
Code for "Exposing React Component functions with fowardRef and useRef" Article
import { useRef } from 'react';
import { Input } from './Input';
const App = () => {
const inputRef = useRef(null);
const handleSubmit = (event) => {
event.preventDefault();
const value = inputRef.current.getValue();
@shameemreza
shameemreza / forwardRef-anduseRef.jsx
Created April 2, 2023 13:41
Code for "Exposing React Component functions with fowardRef and useRef" Article
import { forwardRef, useRef } from 'react';
const Input = forwardRef((props, ref) => {
const inputRef = useRef(null);
const getValue = () => {
return inputRef.current.value;
}
const isValid = () => {