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 / gist:4074021
Last active April 6, 2017 15:23
WooCommerce - Remove the "Related Products" section from a template by removing the related posts query arguments.
<?php
/*
* wc_remove_related_products
*
* Clear the query arguments for related products so none show.
* Add this code to your theme functions.php file.
*/
function wc_remove_related_products( $args ) {
return array();
}
@growdev
growdev / gist:4601948
Last active December 11, 2015 12:38
Detecting version of WooCommerce for Payment Gateways to make them compatible with WC 2.0
<?php
/*
* Use this in __construct() to set appropriate options update
*/
if ( preg_match('/1\.[0-9]*\.[0-9]*/', WOOCOMMERCE_VERSION )){
// 1.*.*
add_action('woocommerce_update_options_payment_gateways', array( $this, 'process_admin_options'));
} else {
// 2.*.*
@growdev
growdev / gist:5051444
Last active February 3, 2022 02:26
Add Buttons to WooCommerce Edit Order screen
<?php
add_action('woocommerce_order_actions', array( $this, 'my_order_actions' ));
add_action('woocommerce_process_shop_order_meta', array( $this, 'my_process_order_meta'), 20, 2 );
function my_order_actions( $post_id ) {
?>
<li class="wide"><input type="submit" class="button tips" name="my_button" value="<?php _e('Do Something', 'woocommerce'); ?>" data-tip="<?php _e('Put tip here.', 'woocommerce'); ?>" /></li>
<?php
@growdev
growdev / gist:5205887
Created March 20, 2013 16:02
custom shipping message on checkout screen.
<?php
add_action( 'woocommerce_before_checkout_form', 'my_custom_shipping_message' );
function my_custom_shipping_message( ) {
global $woocommerce;
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
$_product = $values['data'];
@growdev
growdev / gist:5210074
Last active December 15, 2015 05:39
WooCommerce 2.0.4 - Change number of columns of thumbnails for Up Sells on product page.
<?php
// first remove the action defined in woocommerce-hooks.php
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
// modeled off of the woocommerce_upsell_display() function in woocommerce-template.php
// change $columns to desired number of columns
function my_woocommerce_upsell_display( $posts_per_page = '-1', $columns = 5, $orderby = 'rand' ) {
woocommerce_get_template( 'single-product/up-sells.php', array(
'posts_per_page' => $posts_per_page,
// Twitter Feed
add_shortcode( 'tweet-tweet', 'infom_get_twitter_feed' );
function infom_get_twitter_feed( $atts ) {
extract(shortcode_atts(array(
'handle' => 'krogsgard',
'count' => '1'
), $atts));
$handle = sanitize_text_field( $handle );
$count = intval( $count );
@growdev
growdev / gist:5348814
Created April 9, 2013 19:53
WooCommerce - Change Number of Related Products displayed on the Product page
<?php
// Add this to your theme's functions.php file
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
function custom_output_related_products() {
// Display 5 products in 5 columns
woocommerce_related_products( 5, 5 );
}
add_action( 'woocommerce_after_single_product_summary', 'custom_output_related_products', 20 );
@growdev
growdev / gist:7930554
Last active February 3, 2022 02:26
Display Category title then products in page
<?php
add_shortcode( 'growdev_category_list', 'growdev_category_list');
function growdev_category_list( $atts ) {
global $woocommerce_loop;
extract( shortcode_atts( array (
'number' => null,
@growdev
growdev / gist:8674326
Last active February 10, 2022 03:03
WooCommerce Payment Gateway actions after successful order.
<?php
// Add a note to the order. Put return code here if needed.
$order->add_order_note( __('Payment completed', 'woocommerce') );
// Mark the order as complete
$order->payment_complete();
// Empty the cart
$woocommerce->cart->empty_cart();
@growdev
growdev / 0_reuse_code.js
Created June 11, 2014 03:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console