Skip to content

Instantly share code, notes, and snippets.

@robi09
robi09 / eddpricesnnipet.pgp
Last active February 4, 2016 12:36
EDD price manipulation
$variable_pricing = get_post_meta(get_the_ID(), '_variable_pricing', true);
if($variable_pricing) {
// echo edd_get_highest_price_option(get_the_ID());
// echo edd_get_lowest_price_option(get_the_ID());
// echo edd_price_range(get_the_ID());
//Display default variation price
// $prices = edd_get_variable_prices(get_the_ID());
// $price_id = get_post_meta( get_the_ID(), '_edd_default_price_id', true );
// if(isset($prices[$price_id])) {
@robi09
robi09 / kirki_repeater_transport.js
Last active February 4, 2016 19:17
Transport data parse and append for kirki customizer framework repeater field
wp.customize( 'features_items', function( value ) {
value.bind( function( to ) {
//Clear div
$('#features .right_content').empty();
//Decode content
to = JSON.parse(decodeURIComponent(to.replace(/%2F/g, " ")));
//Create array
@robi09
robi09 / gist:289e00a1bc3dcb3b3a26
Created January 22, 2016 08:26 — forked from corsonr/gist:3d0425deaa80c601d454
WooCommerce: custom variations settings
<?php
// Add Variation Settings
add_action( 'woocommerce_product_after_variable_attributes', 'variation_settings_fields', 10, 3 );
// Save Variation Settings
add_action( 'woocommerce_save_product_variation', 'save_variation_settings_fields', 10, 2 );
/**
* Create new fields for variations
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
@robi09
robi09 / woocommerce_available_variation.php
Created November 9, 2015 08:19
WooCommerce display variation same price
add_filter('woocommerce_available_variation', , 10, 3);
function woocommerce_Variable_same_price($value, $object = null, $variation = null) {
if ($value['price_html'] == '') {
$value['price_html'] = '<span class="price">' . $variation->get_price_html() . '</span>';
}
return $value;
}
@robi09
robi09 / woocommerce_ajax_variation_threshold.php
Last active June 9, 2016 08:29
WooCommerce Variation Ajax Threshold
add_filter( 'woocommerce_ajax_variation_threshold', 'woocommerce_ajax_variation_threshold', 10, 2 );
function woocommerce_ajax_variation_threshold( $qty, $product ) {
return 10000;
}
@robi09
robi09 / gist:37e4cfd5f9dc42d8eed3
Created October 29, 2015 09:36
get latest page by template
function get_pages_by_template($template, $count = 1) {
$pages = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => $template,
'number' => $count
));
$return = array();
foreach($pages as $page){
@robi09
robi09 / gist:3b22229a615ab519dcbf
Created October 28, 2015 11:00
Get woocommerce pages links
//Shop page URL
$shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) );
//My Account URL
$myaccount_page_id = get_option( 'woocommerce_myaccount_page_id' );
if ( $myaccount_page_id ) {
$myaccount_page_url = get_permalink( $myaccount_page_id );
}
//Cart URL
@robi09
robi09 / gist:178511def1a6c3bd46ae
Created October 14, 2015 09:19
WordPress - Get text domain function
/**
* Get text domain
*/
if(!function_exists('get_textdomain')) {
function get_textdomain() {
$default_headers = array( 'td' => 'Text Domain');
$text_domain = get_file_data(get_stylesheet_uri(), $default_headers );
if(array_key_exists('td', $text_domain)) {
return $text_domain['td'];