Skip to content

Instantly share code, notes, and snippets.

View lukecav's full-sized avatar
Translucent form radiates

Luke Cavanagh lukecav

Translucent form radiates
View GitHub Profile
@lukecav
lukecav / Queries
Created July 5, 2023 17:43
Set all product inventory stock to zero in WooCommerce
UPDATE wp_postmeta pm
INNER JOIN wp_wc_product_meta_lookup pml
ON pm.post_id = pml.product_id
SET pm.meta_value = '0', pml.stock_quantity = '0'
WHERE pm.meta_key = '_stock';
UPDATE wp_postmeta pm
INNER JOIN wp_wc_product_meta_lookup pml
ON pm.post_id = pml.product_id
SET pm.meta_value = 'outofstock', pml.stock_status = 'outofstock'
@lukecav
lukecav / Queries
Created June 30, 2023 20:52
Delete Action Scheduler actions with a status of failed and canceled and truncate the Action Scheduler logs database table
DELETE FROMwp_actionscheduler_actions WHERE status IN ('failed','canceled')
TRUNCATE wp_actionscheduler_logs
@lukecav
lukecav / style.css
Created June 30, 2023 14:15
Hide the site title on mobile on the homepage in the Astra theme
@media (max-width: 768px) {
.site-branding .site-title {
display: none;
}
}
@lukecav
lukecav / Query
Created June 29, 2023 19:28
Delete disabled webhook data from WooCommerce
DELETE FROM wp_wc_webhooks WHERE status = 'disabled';
@lukecav
lukecav / wp-config.php
Created June 28, 2023 20:21
Enable lazy loading asynchronously in the Smush plugin
define( 'WP_SMUSH_ASYNC_LAZY', true );
@lukecav
lukecav / Commands
Created June 27, 2023 19:27
WPVulnerability WP-CLI support
wp wpvulnerability core
wp wpvulnerability plugins
wp wpvulnerability themes
@lukecav
lukecav / style.css
Last active April 23, 2024 13:24
Hide Save payment information to my account for future purchases checkbox in Checkout Page in WooCommerce Stripe Payment Gateway
.form-row.woocommerce-SavedPaymentMethods-saveNew.woocommerce-validated {
display: none;
}
@lukecav
lukecav / functions.php
Created June 19, 2023 20:28
Executive the cart-fragments script only on specific pages in WooCommerce
add_filter( 'woocommerce_get_script_data', function( $script_data, $handle ) {
if ( 'wc-cart-fragments' === $handle ) {
if ( is_woocommerce() || is_cart() || is_checkout() ) {
return $script_data;
}
@lukecav
lukecav / Links
Last active June 19, 2023 20:29
cPanel v112 CentOS 7, CloudLinux 6 and 7, and RHEL 7 deprecation
@lukecav
lukecav / functions.php
Created May 26, 2023 20:09
Remove the sales price and use regular price when the stock is zero in WooCommerce
// Remove sale price and use regular price when stock is 0
function remove_sale_price_on_zero_stock( $price, $product ) {
// Check if the product is on sale and has stock
if ( $product->is_on_sale() && $product->get_stock_quantity() <= 0 ) {
$regular_price = $product->get_regular_price();
$price = wc_price( $regular_price ); // Use regular price instead of sale price
}
return $price;
}
add_filter( 'woocommerce_product_get_price', 'remove_sale_price_on_zero_stock', 10, 2 );