Skip to content

Instantly share code, notes, and snippets.

View tradesouthwest's full-sized avatar
Working remotely

Larry tradesouthwest

Working remotely
View GitHub Profile
global $product;
global $woocommerce;
$idd = get_the_ID();
//Displaying a WooCommerce product price:
$sale_price = $product->get_sale_price();
$regular_price = $product->get_regular_price();
// Displaying a WooCommerce price Currency:
@jpgninja
jpgninja / migrate-wordpress-db.sql
Last active February 3, 2017 07:18
Quick way to update WordPress DB during migration. Eliminates the need for running Find & Replace.
/* HTTP */
UPDATE wp_options SET option_value = replace(option_value, 'http://OLDDOMAIN.com', 'http://NEWDOMAIN.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://OLDDOMAIN.com','http://NEWDOMAIN.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://OLDDOMAIN.com', 'http://NEWDOMAIN.com');
/* HTTP + WWW */
UPDATE wp_options SET option_value = replace(option_value, 'http://www.OLDDOMAIN.com', 'http://NEWDOMAIN.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.OLDDOMAIN.com','http://NEWDOMAIN.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.OLDDOMAIN.com', 'http://NEWDOMAIN.com');
<?php
/**
* Plugin Name: Woocommerce Vendors Bookings Management
* Description: Allows vendors to manage their bookings in the frontend
* Version: 1.0.0
* Author: Liam Bailey
* Author URI: http://webbyscots.com/
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
@mikaelz
mikaelz / delete-all-woocommerce-products.php
Last active April 30, 2024 06:07
Remove all WooCommerce products from database via SQL
<?php
require dirname(__FILE__).'/wp-blog-header.php';
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')");
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'");
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)");
$wpdb->query("DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_posts WHERE post_type IN ('product','product_variation')");
@aahan
aahan / wp-code-shortcode.php
Last active March 28, 2024 19:27
Enclose code blocks within [code] shortcode, and let PHP and WordPress take care of the rest.
<?php
/*
* Functionality to set up custom shortcode correctly.
*
* This function is attached to the 'the_content' filter hook.
*/
add_filter( 'the_content', 'run_bbcodes', 7 );
function run_bbcodes( $content ) {
@webaware
webaware / gist:6260468
Last active June 6, 2023 18:00
WooCommerce purchase page add-to-cart with quantity and AJAX, without customising any templates. See blog post for details: http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
<?php
/**
* start the customisation
*/
function custom_woo_before_shop_link() {
add_filter('woocommerce_loop_add_to_cart_link', 'custom_woo_loop_add_to_cart_link', 10, 2);
add_action('woocommerce_after_shop_loop', 'custom_woo_after_shop_loop');
}
add_action('woocommerce_before_shop_loop', 'custom_woo_before_shop_link');
@webaware
webaware / add-to-cart.php
Last active October 22, 2023 05:55 — forked from mikejolley/functions.php
WooCommerce purchase page add-to-cart with quantity and AJAX, by customising the add-to-cart template in the WooCommerce loop. See blog post for details: http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
<?php
/**
* Loop Add to Cart -- with quantity and AJAX
* requires associated JavaScript file qty-add-to-cart.js
*
* @link http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
* @link https://gist.github.com/mikejolley/2793710/
*/
// add this file to folder "woocommerce/loop" inside theme