Skip to content

Instantly share code, notes, and snippets.

@tuongpgjz
tuongpgjz / guide.txt
Last active April 6, 2023 15:47
SIze guide button - WCPA addons custom
/*
Tạo element paragraph trước element size, đặt class là `float-position-element` trong mục Advanced của element.
Thay thế block UX id `lightbox-sizechart` bằng block chứa size-chart của bạn.
Nội dung element: <a href="#lightboxsizechart" target="_self" class="button secondary is-xsmall custom-sizeguide"><span>Size Guide</span></a>[lightbox width="800px" id="lightboxsizechart"][block id="lightbox-sizechart"][/lightbox]
Demo: https://greencity.woocodex.com/product/jesus-is-my-god-all-over-printed-shirts-221220/
*/
@tuongpgjz
tuongpgjz / run.sql
Created October 12, 2022 02:55
Remove all empty categories in WooCommerce
-- Run this SQL commands from PhpMyAdmin or similar ways
-- change the wp_ to your tables prefix to make it works
-- Script from SalesGen.io
DELETE FROM wp_term_taxonomy WHERE taxonomy = 'product_cat' AND count = 0;
DELETE t FROM wp_terms t LEFT JOIN wp_term_taxonomy tt ON tt.term_id = t.term_id WHERE tt.term_id IS NULL;
@tuongpgjz
tuongpgjz / run.sql
Created October 12, 2022 02:53
Correct product count on categories WooCommerce - SQL
-- Run this SQL commands from PhpMyAdmin or similar ways
-- change the wp_ to your tables prefix to make it works
-- Script from SalesGen.io
UPDATE wp_term_taxonomy tt SET count = (SELECT COUNT(object_id) FROM wp_term_relationships WHERE term_taxonomy_id = tt.term_taxonomy_id) WHERE taxonomy = 'product_cat';
@tuongpgjz
tuongpgjz / price.sql
Created July 18, 2022 14:39
Update product price base on category
-- SalesGen.io
-- Change 'category name' by your category name
-- Reduce current price 5
update `wp_postmeta` SET meta_value = meta_value - 5 WHERE meta_key IN ('_regular_price', '_price') AND meta_value <> '' AND post_id IN (SELECT object_id from wp_term_relationships WHERE term_taxonomy_id IN(SELECT term_taxonomy_id FROM `wp_term_taxonomy` WHERE taxonomy = 'product_cat' AND term_id IN (SELECT term_id FROM `wp_terms` WHERE name = 'category name')));
-- Increase current price 5
update `wp_postmeta` SET meta_value = meta_value + 5 WHERE meta_key IN ('_regular_price', '_price') AND meta_value <> '' AND post_id IN (SELECT object_id from wp_term_relationships WHERE term_taxonomy_id IN(SELECT term_taxonomy_id FROM `wp_term_taxonomy` WHERE taxonomy = 'product_cat' AND term_id IN (SELECT term_id FROM `wp_terms` WHERE name = 'category name')))
@tuongpgjz
tuongpgjz / gist:b2453c4cb1e6b61e80e580c823304ea4
Last active June 23, 2022 09:48
Remove WooCommerce products by category name or a part of category name
-- replace category_name by your category name
DELETE FROM wp_posts WHERE ID IN (SELECT object_id from wp_term_relationships WHERE term_taxonomy_id IN(SELECT term_taxonomy_id FROM `wp_term_taxonomy` WHERE taxonomy = 'product_cat' AND term_id IN (SELECT term_id FROM `wp_terms` WHERE name like '%category_name%')))
@tuongpgjz
tuongpgjz / delete trash product.sql
Created June 22, 2022 07:47
Delete trash product by mysql
-- Delete product variants
DELETE FROM wp_posts WHERE post_type = 'product_variation' AND post_parent IN (DELETE FROM wp_posts WHERE post_type = 'product' AND post_status = 'trash');
-- Delete main product
DELETE FROM wp_posts WHERE post_type = 'product' AND post_status = 'trash';
-- clean metapost
DELETE pm
FROM wp_postmeta pm
@tuongpgjz
tuongpgjz / functions.php
Last active May 15, 2022 14:10
remove price range on product page woocommerce
<?php
// SalesGen.io
// WooCommerce plugins, woocommerce upsell, woocommerce buy more save more
/*** Follow Steps ***/
// 1 Put the code below into the functions.php of your theme
add_filter('woocommerce_get_price_html', 'salesgen_hide_variation_price', 99, 2);
function salesgen_hide_variation_price( $v_price, $v_product ) {
@tuongpgjz
tuongpgjz / paypal-duplicate-custom.css
Created April 1, 2022 15:14
Hide some duplicate paypal button on WooCommerce checkout page
div[id^=zoid-paypal-buttons]:nth-child(3),
div[id^=zoid-paypal-buttons]:nth-child(1) {
display: none!important;
}
@tuongpgjz
tuongpgjz / functions.php
Last active April 15, 2023 12:57
Auto update Product Addons price to top position
/*
Anthony from SalesGen.io
Demo page https://greencity.woocodex.com/product/let-your-faith-be-bigger-than-your-fear-all-over-printed-shirts-2/
Copy this script into your functions.php file theme
*/
add_action('wp_footer', function(){
/* Code By SalesGen.io */
?>
@tuongpgjz
tuongpgjz / functions.php
Created January 1, 2022 13:38
Replace woocommerce product tab with new one
<?php
//SalesGen.io
//remove reviews and additional_information tab
add_filter( 'woocommerce_product_tabs', 'salesgen_remove_product_tabs', 98 );
function salesgen_remove_product_tabs( $tabs ) {
if(is_product()){
unset( $tabs['additional_information'] ); // Remove the additional information tab
unset( $tabs['reviews'] ); // Remove the additional information tab