Skip to content

Instantly share code, notes, and snippets.

View growdev's full-sized avatar
😎
Future's so bright...

Daniel Espinoza growdev

😎
Future's so bright...
View GitHub Profile
@growdev
growdev / functions.php
Created July 21, 2016 16:10
WooCommerce - Remove Shipping Method if Shipping Zone Selected
<?php
add_filter( 'woocommerce_available_payment_gateways', 'filter_gateways', 1);
function filter_gateways( $gateways ) {
$method = WC()->session->get( 'chosen_shipping_methods' );
// get the value of the radio button on the checkout page
if ( 'flat_rate:1' != $method[0] ) {
unset( $gateways['paypal'] );
}
@growdev
growdev / exif_test.php
Created July 12, 2016 16:28
EXIF Data
<?php
echo "START\n";
$file_name ='IMG_2869.JPG';
$exif = exif_read_data( $file_name, 'IDF0' );
echo $exif===false ? "No header data found.<br />\n" : "Image contains headers<br />\n";
$exif = exif_read_data( $file_name, 0, true );
echo "$file_name:\n";
@growdev
growdev / trigger_email.php
Created March 25, 2016 20:00
Trigger WooCommerce email from WP-CLI
<?php
/**
* This can be run by wp-cli to trigger an email send.
* The email is determined by the action. The one below will trigger the "new order email"
*/
WC()->mailer();
$order_id = '260'; // this order needs to exist in your store
$args = array( 'order_id' => $order_id );
@growdev
growdev / report.php
Created September 25, 2015 04:05
Search WooCommerce orders for line items with qty > 1, and multiple 'pa_color' assignments.
<?php
echo "START\n";
// Setup arguments for WP_Query
// set post type to WooCommerce orders
// set post status to published
// set fields to return just the post IDs
// set posts per page to -1 so all records are returned
$args = array(
@growdev
growdev / get_random_woocommerce_products.php
Created September 16, 2015 23:35
WooCommerce Get random Products
<?php
add_shortcode( 'random_products', 'growdev_random_products' );
function growdev_random_products( ) {
$meta_query = WC()->query->get_meta_query();
@growdev
growdev / test.php
Created September 10, 2015 21:38
Get Product Discounted Price
<?php
// add qty to cart to trigger dynamic pricing
$cart_item_key = WC()->cart->add_to_cart('8','300');
$product = wc_get_product( '8' );
echo "NAME: " . $product->get_title() . "\n";
$price = $product->get_price();
echo "PRICE: " . $price . "\n";
@growdev
growdev / sample_functions.php
Last active January 20, 2023 06:43
Moving the location of the WooCommerce Variable Product Description on the product page
<?
/* Add this to your theme's functions.php to move the variation description display to a different location
* on the product page.
*/
add_action('plugins_loaded', 'move_variation_description', 50);
function move_variation_description(){
// Remove the hook from the original location
@growdev
growdev / remove-page-tracking.php
Last active August 29, 2015 14:26
Remove page tracking from EDD EET
<?php
if ( function_exists( 'EDD_Enhanced_Ecommerce_Tracking' ) ) {
remove_action( 'wp_footer', array( EDD_Enhanced_Ecommerce_Tracking()->front_end, 'print_js_tracking_code' ) );
}
@growdev
growdev / gist:74182260398e26615a85
Created June 17, 2015 15:26
Use WooCommerce Advanced Messages with WooCommerce Subscriptions
<?php
/**
* This code snippet adds a "Active Subscriber" Yes/No to the conditional box of WooCommerce Advanced Messages.
* You can use this to display messages to customers with an active subscription.
*/
/**
* Add the option to the condition drop down