Skip to content

Instantly share code, notes, and snippets.

View jswebschmiede's full-sized avatar
🏠
Working from home

Joerg Schoeneburg jswebschmiede

🏠
Working from home
View GitHub Profile
@jswebschmiede
jswebschmiede / wc-show-cart-contents-total-ajax.php
Created April 13, 2022 12:00 — forked from woogists/wc-show-cart-contents-total-ajax.php
[Theming Snippets] Show cart contents / total Ajax
/**
* 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 / functions.php
Created April 14, 2022 22:46 — forked from corsonr/functions.php
Display WooCommerce product variations dropdown select on the shop page
<?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 / functions.php
Created April 16, 2022 09:14 — forked from claudiosanches/functions.php
WooCommerce - Hide shipping rates when free shipping is available.
<?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();
<?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 / attributes-as-options.php
Created April 19, 2022 22:08 — forked from dazecoop/attributes-as-options.php
WooCommerce product attributes as selectable options without variations
<?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 / related-products-same-cat.php
Created April 19, 2022 22:09 — forked from dazecoop/related-products-same-cat.php
In WooCommerce, only show products from same category within Related Products
@jswebschmiede
jswebschmiede / wp-coustom-term-options.php
Created April 19, 2022 22:21 — forked from svebal/wp-coustom-term-options.php
Wordpress Hooks to add coustom term Options
<?php
/**
*
* Add only for parents coustom term Options
* @author rene reimann
* @home http://www.rene-reimann.de
*
* @hook category_add_form_fields Hooks into the category edit page
* @hook edit_tag_form_fields Hooks into the category frontpage
@jswebschmiede
jswebschmiede / hide-shipping-if-free-shipping-is-available.php
Created April 20, 2022 09:54 — forked from JeroenSormani/hide-shipping-if-free-shipping-is-available.php
New - Hide paid shipping rates when free is available. DOES show Local Pickup. Considered ANY shipping rate that is $0 as free (so the 'Free shipping' shipping method is not a requirement)
<?php
/**
* Copy from here to your (child) themes functions.php
* Recommended to do so via FTP.
*/
/**
* Hide all but the free shipping options when free is available.
*
@jswebschmiede
jswebschmiede / wc-hide-all-shipping-if-free-shipping-is-available.php
Created April 20, 2022 10:27 — forked from woogists/wc-hide-all-shipping-if-free-shipping-is-available.php
[General Snippets][Hide other shipping methods when “Free Shipping” is available] Hides all other shipping methods but free_shipping if it’s available. Compatible with Shipping zones.
/**
* 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();
foreach ( $rates as $rate_id => $rate ) {
@jswebschmiede
jswebschmiede / hide-all-shipping-keep-local-free.php
Created April 20, 2022 10:28 — forked from woogists/hide-all-shipping-keep-local-free.php
[General Snippets][Hide other shipping methods, but keep "Local pickup" when “Free Shipping” is available]
/**
* Hide shipping rates when free shipping is available, but keep "Local pickup"
* Updated to support WooCommerce 2.6 Shipping Zones
*/
function hide_shipping_when_free_is_available( $rates, $package ) {
$new_rates = array();
foreach ( $rates as $rate_id => $rate ) {
// Only modify rates if free_shipping is present.
if ( 'free_shipping' === $rate->method_id ) {