Skip to content

Instantly share code, notes, and snippets.

View kosarlukascz's full-sized avatar
😶‍🌫️

Lukáš Kosař kosarlukascz

😶‍🌫️
View GitHub Profile
@kosarlukascz
kosarlukascz / sql.sql
Created December 13, 2022 09:46
show large wp_option
SELECT option_name, length(option_value) AS option_value_length FROM wp_options WHERE autoload='yes' ORDER BY option_value_length DESC LIMIT 10
@kosarlukascz
kosarlukascz / gist:c287943c4082ba2c8c41e825c0739623
Last active November 29, 2021 12:44
Ušetříte do pokladny
add_action('woocommerce_cart_totals_before_order_total', 'wc_discount_total', 99);
add_action('woocommerce_review_order_before_order_total', 'wc_discount_total', 99);
function wc_discount_total()
{
global $woocommerce;
$discount_total = 0;
foreach ($woocommerce->cart->get_cart() as $cart_item_key => $values) {
@kosarlukascz
kosarlukascz / delete add_to_cart&reunds&actions
Last active October 6, 2020 11:00
delete add_to_cart&reunds&actions
delete
FROM `wp_posts`
where `post_type`= 'njt_user_add_to_cart';
delete
FROM `wp_posts`
where `post_type`= 'shop_order_refund';
delete
FROM `wp_posts`
where `post_type`= 'scheduled-action';
DELETE pm
update wp_posts set post_status = 'trash' where post_type = 'shop_order';
DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%');
DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%';
DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy);
DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'));
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'));
DELETE FROM wp_posts WHERE post_type IN ('product','product_variation');
DELETE pm
DELETE FROM wp_comgate_log;
@kosarlukascz
kosarlukascz / Delete all user and their metas
Created February 6, 2020 07:15
Change (1,2) to the main admins IDs
DELETE FROM wp_users WHERE ID NOT in (1,2)
DELETE FROM wp_usermeta WHERE user_id NOT in (1,2)
DELETE pm
FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
WHERE wp.ID IS NULL
@kosarlukascz
kosarlukascz / Upvay RF DB
Last active January 28, 2020 13:29
Create DB tables
CREATE TABLE IF NOT EXISTS wp_upvay_rf_payments (
id mediumint(9) NOT NULL AUTO_INCREMENT,
time time DEFAULT '0000-00-00 00:00:00' NOT NULL,
order_id mediumint(255) NOT NULL,
var_symbol mediumint(255) NOT NULL,
cislo_ucet mediumint(255) NOT NULL,
price mediumint(255) NOT NULL,
status text NOT NULL,
PRIMARY KEY (id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;