Skip to content

Instantly share code, notes, and snippets.

@hemusyl
hemusyl / Shipping Method API
Last active February 18, 2016 07:12 — forked from mikejolley/gist:6713608
Shipping Method API
https://docs.woothemes.com/document/shipping-method-api/
<?php
/*
Plugin Name: Your Shipping plugin
Plugin URI: http://woothemes.com/woocommerce
Description: Your shipping method plugin
Version: 1.0.0
Author: WooThemes
Author URI: http://woothemes.com
*/
<?php
/**
* This code shows pagination for WooCommerce shortcodes when it's embeded on single pages.
* Include into functions.php.
*/
if ( ! is_admin() ) {
// ---------------------- FRONTPAGE -------------------
if ( defined('WC_VERSION') ) {
// front end
function custom_front_scripts() {
wp_enqueue_style( 'front-css', plugins_url('/lib/css/front-css.css', __FILE__), array(), null, 'all' );
wp_enqueue_script( 'front-init', plugins_url('/lib/js/front.init.js', __FILE__) , array('jquery'), null, true );
}
add_action('wp_enqueue_scripts', 'custom_front_scripts' );
// back end
function custom_admin_scripts() {
@hemusyl
hemusyl / gist:eef1bd5bc018c5e9f2e0
Last active August 29, 2015 14:26 — forked from corsonr/gist:9152652
WooCommerce : add custom fields to product variations
<?php
//Display Fields
add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 3 );
//JS to add fields for new variations
add_action( 'woocommerce_product_after_variable_attributes_js', 'variable_fields_js' );
//Save variation fields
add_action( 'woocommerce_process_product_meta_variable', 'save_variable_fields', 10, 1 );
/**
@hemusyl
hemusyl / gist:b46781831d6d7d05687a
Last active August 29, 2015 14:26 — forked from mikejolley/gist:1565309
WooCommerce - Filters to add custom currencies and symbols
add_filter( 'woocommerce_currencies', 'add_my_currency' );
function add_my_currency( $currencies ) {
$currencies['ABC'] = __( 'Currency name', 'woocommerce' );
return $currencies;
}
add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2);
function add_my_currency_symbol( $currency_symbol, $currency ) {
@hemusyl
hemusyl / gist:a32c9d848c506e0ecf85
Created October 9, 2015 13:59 — forked from wcodex/gist:8825693
Custom WordPress search form using bootstrap 3.0
?>
<form class="navbar-form" role="search" action="<?php echo site_url('/'); ?>" method="get" >
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="s" id="search" value="<?php the_search_query(); ?>">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
@hemusyl
hemusyl / new_gist_file.php
Created November 14, 2015 18:47 — forked from nickberens360/new_gist_file.php
wordpress: Full dynamic bootstrap carousel code
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<?php
$args = array(
'post_type' => 'slides1',
'orderby' => 'menu_order title',
'order' => 'ASC',
);
$query = new WP_Query( $args );
@hemusyl
hemusyl / wc-add-images-order-email-table.php
Last active January 22, 2016 15:01 — forked from bekarice/wc-add-images-order-email-table.php
Add images to WooCommerce emails
// Edit order items table template defaults
// https://www.sellwithwp.com/how-to-add-information-to-woocommerce-emails/
function sww_add_wc_order_email_images( $table, $order ) {
ob_start();
$template = $plain_text ? 'emails/plain/email-order-items.php' : 'emails/email-order-items.php';
wc_get_template( $template, array(
'order' => $order,
'items' => $order->get_items(),
@hemusyl
hemusyl / gist:cce281d03c2d2d808bb0
Created January 27, 2016 08:16 — forked from webaware/gist:6260468
WooCommerce purchase page add-to-cart with quantity and AJAX, without customising any templates. See blog post for details: http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
<?php
/**
* start the customisation
*/
function custom_woo_before_shop_link() {
add_filter('woocommerce_loop_add_to_cart_link', 'custom_woo_loop_add_to_cart_link', 10, 2);
add_action('woocommerce_after_shop_loop', 'custom_woo_after_shop_loop');
}
add_action('woocommerce_before_shop_loop', 'custom_woo_before_shop_link');
@hemusyl
hemusyl / functions.php
Created January 30, 2016 05:29 — forked from woogist/functions.php
Set a custom add to cart URL to redirect to
/**
* Set a custom add to cart URL to redirect to
* @return string
*/
function custom_add_to_cart_redirect() {
return 'http://www.yourdomain.com/your-page/';
}
add_filter( 'woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect' );