Skip to content

Instantly share code, notes, and snippets.

View hamidrezayazdani's full-sized avatar
🤕

Hamid Reza Yazdani hamidrezayazdani

🤕
View GitHub Profile
@hamidrezayazdani
hamidrezayazdani / finding-class-shipping-id.jpg
Last active December 4, 2023 12:11
Hide specific shipping method if a shipping class is showing
finding-class-shipping-id.jpg
@hamidrezayazdani
hamidrezayazdani / better-order-editing-page.php
Last active June 16, 2024 07:46
Adding row numbers and distinguishing lines of order items to the order editing page in WooCommerce for a better order editing experience
<?php
/**
* Add row numbers to order items in admin edit order page
*/
function ywp_better_admin_order_editing_items() {
$current_screen = get_current_screen();
if ( empty( $current_screen ) || ! property_exists( $current_screen, 'id' ) ) {
return;
}
<?php
function ywp_fix_woocommerce_admin_order_list_css() {
$custom_css = "
@media screen and (max-width: 782px) {
.post-type-shop_order .wp-list-table tr:not(.is-expanded) td.column-order_number a.order-view, .woocommerce_page_wc-orders .wc-orders-list-table.wp-list-table tr:not(.is-expanded) td.column-order_number a.order-view {
width: calc(100% - 48px - 10ch)!important;
}
}
@hamidrezayazdani
hamidrezayazdani / force-to-refresh-users-browser-cache-for-specific-wc-product.php
Created July 23, 2024 11:05
Force refresh users browser cache for specefic Yoast deleted product redirect
<?php
/**
* Clearing the browser cache for all users who have visited your site can be challenging
* since you can’t directly control their browsers.
* However, you can take some steps to ensure that the updated URL is served to everyone
*/
/**
* Force refresh users browser cache for specefic Yoast deleted product redirect
@hamidrezayazdani
hamidrezayazdani / add-slug-to-attribute-search-result.php
Created January 25, 2025 20:02
Add the slug to attribute selectbox in the WooCommerce product editing page
<?php
/**
* When you have a lot of values in an attribute and some of them have similar names,
* choosing the right value in the attribute field in the product information box is a pain and there is a high chance of mistakes.
* One solution is to consider a different slug for each attribute.
* But the problem is that when searching for values in attributes,
* only the attribute name is displayed to you.
* The code that follows helps you choose the right values by displaying the slug of each value (after its name).
*/