Skip to content

Instantly share code, notes, and snippets.

@mikejolley
mikejolley / gist:1565309
Created January 5, 2012 13:42
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 ) {
@FernE97
FernE97 / tabbed_taxonomy.php
Last active April 30, 2022 03:42
PHP: WordPress custom taxonomy/post query
<?php
$args = array(
'orderby' => 'ID'
);
$terms = get_terms( 'testimonial_category', $args );
?>
<!-- bootstrap tabs -->
<ul class="nav-tabs">
<?php
@webaware
webaware / gist:6260468
Last active June 6, 2023 18:00
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');
@mikejolley
mikejolley / gist:6713608
Last active September 5, 2018 10:59
WooCommerce Shipping Method Skeleton Plugin
<?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
*/
@corsonr
corsonr / gist:7153007
Created October 25, 2013 11:08
woocommerce custom field
// Display Fields
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
// Save Fields
add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' );
function woo_add_custom_general_fields() {
global $woocommerce, $post;
<?php
/*
Plugin Name: woocommerce modal variationn
Plugin URI: #
Description: show modal window with product variations after clicking -add to cart-.
Version: 0.1
Author: Maks Buriy
Author URI: mailto:byymster@gmail.com
License: GPL2
*/
@corsonr
corsonr / gist:9152652
Last active January 19, 2023 22:41
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 );
/**
@technoknol
technoknol / Woocommerce get product category list .php
Last active September 6, 2019 14:21
Woocommerce get product category list
<?php
global $post;
$terms = get_the_terms( $post->ID, 'product_cat' );
foreach ($terms as $term) {
$product_cat_id[] = $term->term_id;
break;
}
print_r (array_filter( array_unique( $product_cat_id ))) ;
@freelancingcare
freelancingcare / wordpress-code-example.php
Last active June 5, 2020 08:40
Wordpress Code Referance From Practical Use
Root url for website
---------------------------------------------------------
<?php site_url(); ?>
<?php bloginfo('url'); ?>
title of specific post/page
---------------------------------------------------------
<?php wp_title(); ?>
Title of site
@mrbobbybryant
mrbobbybryant / gist:e28efc0d84afbead7d0e
Last active June 8, 2017 09:17
WordPress Custom Post Type (Simple)
<?php
function dwwp_register_post_type() {
$args = array('public'=> true, 'label'=> 'Staff');
register_post_type( 'staff', $args);
}
add_action( 'init', 'dwwp_register_post_type' );