Skip to content

Instantly share code, notes, and snippets.

View sirwan's full-sized avatar
🏠
Working from home

Sirwan Qutbi sirwan

🏠
Working from home
View GitHub Profile
@sirwan
sirwan / gist:eead31f1ea3f9cc30ea8ccab2657ac3c
Created August 23, 2018 20:40
Exclude products from a particular category on the shop page
/**
* 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',
@sirwan
sirwan / gist:6bf7723c8eaa3a2c6ef7eff552c6c467
Created August 23, 2018 20:39
Fetch child products in grouped products woocommerce
$product_id = 8;
$product = wc_get_product($product_id);
$product->get_children();
@sirwan
sirwan / gist:4b808b347cec264d0fdd3de659bc32e0
Created August 23, 2018 20:38
Get children of a grouped product
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();
@sirwan
sirwan / gist:fcc7d370d3fbe5fcd63fe4086dad028e
Created August 23, 2018 03:03
Change the price formatting
// 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);
@sirwan
sirwan / gist:5893474
Created June 30, 2013 01:59
timeago() ... on line 29 and packery on line 27 are not changing the Dom .. after I render my snapshots.hb template.
<script type="text/javascript">
(function($) {
var app = $.sammy('.thumbnails', function(){
this.use('Handlebars', 'hb');
this.get('#/', function(context){
//
@sirwan
sirwan / gist:5884227
Created June 28, 2013 12:07
the snapshots get looped and display, but the nested comments on each snapshot looped doesnt show the nested comments.
<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>
@sirwan
sirwan / hack.sh
Created March 31, 2012 23:51 — forked from erikh/hack.sh
OSX For Hackers
#!/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
#