Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Joerg Schoeneburg jswebschmiede

🏠
Working from home
View GitHub Profile
@jswebschmiede
jswebschmiede / attributes-as-options.php
Created Apr 19, 2022 — forked from dazecoop/attributes-as-options.php
WooCommerce product attributes as selectable options without variations
View attributes-as-options.php
<?php
/**
* List available attributes on product page in a drop-down selection
*/
add_action('woocommerce_before_add_to_cart_button', 'list_attributes_on_product_page');
function list_attributes_on_product_page() {
global $product;
$attributes = $product->get_attributes();
@jswebschmiede
jswebschmiede / gist:eb903142ac2ee0f100672f600f3ce9f3
Created Apr 19, 2022
Wordpress - WooCommerce get physical store address
View gist:eb903142ac2ee0f100672f600f3ce9f3
// The main address pieces:
$store_address = get_option( 'woocommerce_store_address' );
$store_address_2 = get_option( 'woocommerce_store_address_2' );
$store_city = get_option( 'woocommerce_store_city' );
$store_postcode = get_option( 'woocommerce_store_postcode' );
// The country/state
$store_raw_country = get_option( 'woocommerce_default_country' );
// Split the country/state
View woocommerce_loop-custom.php
<?php
if(!function_exists('wc_get_products')) {
return;
}
$paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1;
$ordering = WC()->query->get_catalog_ordering_args();
$ordering['orderby'] = array_shift(explode(' ', $ordering['orderby']));
$ordering['orderby'] = stristr($ordering['orderby'], 'price') ? 'meta_value_num' : $ordering['orderby'];
@jswebschmiede
jswebschmiede / functions.php
Created Apr 16, 2022 — forked from claudiosanches/functions.php
WooCommerce - Hide shipping rates when free shipping is available.
View functions.php
<?php
/**
* Hide shipping rates when free shipping is available.
* Updated to support WooCommerce 2.6 Shipping Zones.
*
* @param array $rates Array of rates found for the package.
* @return array
*/
function my_hide_shipping_when_free_is_available( $rates ) {
$free = array();
@jswebschmiede
jswebschmiede / functions.php
Created Apr 14, 2022 — forked from corsonr/functions.php
Display WooCommerce product variations dropdown select on the shop page
View functions.php
<?php
// Display variations dropdowns on shop page for variable products
add_filter( 'woocommerce_loop_add_to_cart_link', 'woo_display_variation_dropdown_on_shop_page' );
function woo_display_variation_dropdown_on_shop_page() {
global $product;
if( $product->is_type( 'variable' )) {
@jswebschmiede
jswebschmiede / wc-show-cart-contents-total-ajax.php
Created Apr 13, 2022 — forked from woogists/wc-show-cart-contents-total-ajax.php
[Theming Snippets] Show cart contents / total Ajax
View wc-show-cart-contents-total-ajax.php
/**
* Show cart contents / total Ajax
*/
add_filter( 'woocommerce_add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment' );
function woocommerce_header_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
@jswebschmiede
jswebschmiede / wc-min-order-amount.php
Created Apr 13, 2022 — forked from woogists/wc-min-order-amount.php
Set a minimum order amount for checkout
View wc-min-order-amount.php
/**
* Set a minimum order amount for checkout
*/
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
function wc_minimum_order_amount() {
// Set this variable to specify a minimum order value
$minimum = 50;
View breadcrumbs-functions.php
<?php
/*=============================================
= BREADCRUMBS =
=============================================*/
// to include in functions.php
function the_breadcrumb() {
$sep = ' > ';
View wordpress load_inline_svg
<?php
/**
* Load an inline SVG.
*
* @param string $filename The filename of the SVG you want to load.
*
* @return string The content of the SVG you want to load.
*/
function load_inline_svg( $filename ) {
View gist:ab7b0af66d27e495d6befae83cd7aa84
<!-- contactform.php -->
<div class="cf" id="cf">
<form action="javascript:void(0);">
<div><input type="text" name="name" placeholder="Name"/><span class="error"></span></div>
<div><input type="text" name="email" placeholder="Email"/><span class="error"></span></div>
<div><textarea name="message" placeholder="Message"></textarea><span class="error"></span></div>
<div><button type="submit">Submit</button> <span class="loader"></span></div>
</form>
</div>