Skip to content

Instantly share code, notes, and snippets.

@attilabacso
attilabacso / select-woo-users-no-billing-name.sql
Created March 8, 2023 10:32
SELECT ALL USERS WITH NO BILLING FIRST NAME IN WOOCOMMERCE
-- SELECT ALL USERS WITH NO BILLING FIRST NAME IN WOOCOMMERCE
SELECT *
FROM wp_users AS wpu
INNER JOIN wp_usermeta wpum
ON wpum.user_id = wpu.ID
WHERE wpu.ID IN (
SELECT wp_users.ID
FROM wp_users
# GET ALL WOOCOMMERCE PRODUCTS BY CATEGORY ID (124)
SELECT ID, post_title
FROM wp_posts
INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
INNER JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)
WHERE wp_term_taxonomy.term_id IN(124)
GROUP BY ID
<?php
$json = file_get_contents("php://input");
$data = (array) json_decode($json, true);
if ( array_key_exists('name', $data) ) {
$name = (string) $data['name'];
$value = (int) $data['value'];
$text = (string) $data['text'];
}
// SELECT ON CHANGE VALUES FETCHING TO PHP
document.querySelectorAll(`select.collect`).forEach(dropdown =>
dropdown.addEventListener(`change`, (e) => {
// GET VALUES
let value = e.target.value;
let text = dropdown.options[dropdown.selectedIndex].text;
let price = dropdown.options[dropdown.selectedIndex].getAttribute(`attr-price`);
# Delete all WooCommerce orders, order_meta and order post_meta datas
DELETE FROM wp_woocommerce_order_itemmeta;
DELETE FROM wp_woocommerce_order_items;
DELETE FROM wp_comments WHERE comment_type = 'order_note';
DELETE FROM wp_postmeta WHERE post_id IN ( SELECT ID FROM wp_posts WHERE post_type = 'shop_order' );
DELETE FROM wp_posts WHERE post_type = 'shop_order';
/*
This code should be include in functions.php
*/
/* Custom 'super-editor' user role (ID, not label) */
// This is the name of custom user role, you can change to anything, but this role should be exists
// You can add any custom user role eg. with Vladimir Garagulya User Role Editor plugin
if (current_user_can( 'super-editor' )) {
@attilabacso
attilabacso / jquery_phone_number_restriction.js
Last active June 20, 2017 16:51
Jquery Phone number restriction
// Phone number restriction for input_10_4 field
// Start with + character
$('#input_10_4').val('+');
$('#input_10_4').attr('data-initial', '+');
// Cannot delete the + character
$("#input_10_4").on("keyup", function() {
// Put functions.php
add_filter('give_format_amount', 'give_remove_thousands_seperator');
function give_remove_thousands_seperator($amount, $decimals = true) {
$thousands_sep = '';
$decimal_sep = give_get_option( 'decimal_separator', '.' );
if ( empty( $amount ) ) {
<?php
/* Custom woocommerce loop and add to isotope container */
// Display woo products order by price
$args=array(
'post_type' => 'product',
'post_status' => 'publish',
'orderby' => 'meta_value_num',
'meta_key' => '_price',
<?php
//Set minimum order amount
function minimum_order_func(){
global $woocommerce;
if (is_checkout()){
$minorder = 1500;
// If the cart is empty and the order_total less than $minorder (1500)