This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// https://businessbloomer.com/woocommerce-remove-specific-category-shop-loop/ | |
// https://stackoverflow.com/questions/34684881/hide-products-from-users-who-are-not-logged-in-using-tags/34689768#34689768 | |
add_action( 'woocommerce_product_query', 'show_hide_products_category_shop' ); | |
function show_hide_products_category_shop( $q ) { | |
$tax_query = (array) $q->get( 'tax_query' ); | |
if ( is_user_logged_in() ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Change shipping based on quantity purchased. | |
// https://easywebdesigntutorials.com/adjust-shipping-price-when-quantity-changes/ | |
// https://businessbloomer.com/woocommerce-setup-tiered-shipping-rates-order-amount/ | |
add_filter( 'woocommerce_package_rates', 'bbloomer_woocommerce_tiered_shipping', 10, 2 ); | |
function bbloomer_woocommerce_tiered_shipping( $rates, $package ) { | |
$threshold1 = 2; | |
$threshold2 = 3; | |
if ( WC()->cart->get_cart_contents_count() < $threshold1 ) { | |
unset( $rates['flat_rate:6'], $rates['flat_rate:8'] ); | |
} elseif ( WC()->cart->get_cart_contents_count() < $threshold2 ){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 1. Adds a custom field. NB. I am using some Norwegian words in the below text. | |
* 2. Then adds a validate error message if person does not fill out the field. | |
* 3. Then adds the custom field to the order page. | |
https://businessbloomer.com/woocommerce-add-custom-checkout-field-php/ | |
https://businessbloomer.com/woocommerce-add-shipping-phone-checkout/ | |
https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/#section-6 | |
*/ | |
add_action( 'woocommerce_before_order_notes', 'my_custom_checkout_field' ); | |
function my_custom_checkout_field( $checkout ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Initial code from: https://gist.github.com/kloon/6495019 | |
As the code did not fully work I received help from Helga the Viking | |
with this gist: https://gist.github.com/helgatheviking/ff8792fbb12f5c5367c816b8a46c70ad | |
* Change the quantity input to select. | |
* @param array $args Args for the input. | |
* @param WC_Product|null $product Product. | |
* @param boolean $echo Whether to return or echo|string. | |
* @return string | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* --------- Adds custom fields using filters. ------ | |
The below custom fields shows various types one can use. | |
It is then displayed in the backend Order Details page and in admin and customer e-mails. | |
Checkboxes by default result only show the number 1 when clicked. I have added code so that when the a checkbox is clicked it will | |
show text such as On and Yes. Checkbox is also pre-selected. | |
Tutorial: https://easywebdesigntutorials.com/woocommerce-modifying-the-checkout-page/ | |
*/ | |
// Initial inspiration: https://businessbloomer.com/woocommerce-add-shipping-phone-checkout/ | |
// My Custom Fields |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GENESIS get featured image. | |
// 1. Sets the featured image. | |
// 2. If no featured image then get image from category. | |
// 3. If no category image then get the first post image. | |
// 4. If no post image or category image then set a fallback image. | |
// Add to your functions file. | |
// Resources | |
// https://wordpress.org/support/topic/make-first-image-in-post-featured-if-no-featured-is-set?replies=9 | |
// http://wpsites.net/web-design/add-default-featured-image-for-each-post-in-a-category/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add or remove notes after the comment box | |
// | |
add_filter( 'comment_form_defaults', 'sp_remove_comment_form_allowed_tags' ); | |
function sp_remove_comment_form_allowed_tags( $defaults ) { | |
$defaults['comment_notes_after'] = 'An extra comment'; | |
return $defaults; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* STYLING NINJA FORMS - add to your stylesheet and adjust */ | |
/* The full form */ | |
#ninja_forms_form_1_wrap { | |
background-color: #f89a16; | |
padding: 20px; | |
border: 2px solid #ccc; | |
border-radius: 8px; | |
box-shadow: 0px 3px 5px #444; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/***************************** | |
*Add a custom Welcome Dashboard Panel | |
*****************************/ | |
function my_welcome_panel() { | |
?> | |
<div class="top-welcome-panel-content"> | |
<div class="top-welcome-panel-logo" style="height: 120px; padding: 5px;text-align: center;"> | |
<!-- Adds a logo top left--> |
NewerOlder