This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Exclude products from a particular category on the shop page | |
*/ | |
function custom_pre_get_posts_query( $q ) { | |
$tax_query = (array) $q->get( 'tax_query' ); | |
$tax_query[] = array( | |
'taxonomy' => 'product_cat', | |
'field' => 'slug', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$product_id = 8; | |
$product = wc_get_product($product_id); | |
$product->get_children(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here is a simple example. | |
/** | |
* Test creating a new grouped product. | |
* | |
* @since 2.7.0 | |
*/ | |
function test_grouped_product_create() | |
{ | |
$simple_product = WC_Helper_Product::create_simple_product(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check out these two snippets. One for altering the price and the other for altering the price’s html format. | |
function return_custom_price($price, $product) { | |
global $post, $blog_id; | |
$price = get_post_meta($post->ID, '_regular_price'); | |
$post_id = $post->ID; | |
$price = ($price[0]*2.5); | |
return $price; | |
} | |
add_filter('woocommerce_get_price', 'return_custom_price', 10, 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
(function($) { | |
var app = $.sammy('.thumbnails', function(){ | |
this.use('Handlebars', 'hb'); | |
this.get('#/', function(context){ | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/template" id="myuploads-template"> | |
<h3>cached snaps</h3> | |
<ul class="thumbnails"> | |
<% _.each(snapshots, function(snapshot){ %> | |
<li> | |
<div class="thumbnail"> | |
<a href="/<%=snapshot.get('username')%>/<%=snapshot.get('slug_title')%>"> | |
<img id="snapshot-thumb" src="<%=snapshot.get('thumbnail_url')%>" alt="<%=snapshot.get('title')%>" width="<%=snapshot.get('thumbnail_width')%>" height="<%=snapshot.get('thumbnail_height')%>"> | |
</a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |