Skip to content

Instantly share code, notes, and snippets.

@jagels
jagels / functions.php
Last active March 15, 2017 11:51
Endre valutasymbol fra kr til ,- for norske nettbutikker på WooCommerce
//changed currency from kr to ,-
add_filter('woocommerce_currency_symbol', 'jagels_change_existing_currency_symbol', 10, 2);
function jagels_change_existing_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'NOK': $currency_symbol = ',-'; break;
}
return $currency_symbol;
}
@jagels
jagels / functions.php
Created March 14, 2017 09:43
Remove products from a specific category on the shop page in WooCommerce
//Remove the outlet category from the shop page
add_action( 'pre_get_posts', 'custom_pre_get_posts_query' );
function custom_pre_get_posts_query( $q ) {
if ( ! $q->is_main_query() ) return;
if ( ! $q->is_post_type_archive() ) return;
if ( ! is_admin() && is_shop() ) {
$q->set( 'tax_query', array(array(
'taxonomy' => 'product_cat',
@jagels
jagels / functions.php
Created March 14, 2017 09:45
Add text field above "Proceed to checkout" button on the cart page in WooCommerce
//Add shipping info above the proceed to checkout button
add_action('woocommerce_proceed_to_checkout', 'jagels_custom_checkout_field');
function jagels_custom_checkout_field() {
echo '<p><small>Levering innen 2-5 virkedager.</small></p>';
}
@jagels
jagels / functions.php
Last active March 14, 2017 09:49
Remove a specific category from the category widget (sidebar) in WooCommerce
//Remove the Black friday category from category widget
function jagels_exclude_widget_categories($args){
$exclude = "99"; // The IDs of the excluding categories separated by commas.
$args["exclude"] = $exclude;
return $args;
}
add_filter('woocommerce_product_categories_widget_args','jagels_exclude_widget_categories');
@jagels
jagels / jquery.js
Created April 24, 2017 13:51
Hente postnummer fra Bring API
$("input[name=postnummer]").on("change", function () {
$this = $(this);
$.getJSON("https://fraktguide.bring.no/fraktguide/api/postalCode.json?country=no&pnr=" + $(this).val() + "&callback=?", function (json) {
$(".poststed").text((json.result));
$("input[name=poststed]").val((json.result));
});
});