Skip to content

Instantly share code, notes, and snippets.

View karks88's full-sized avatar

Eric Karkovack karks88

View GitHub Profile
@karks88
karks88 / handy-links-widget.php
Last active March 25, 2023 00:31
Handy Links Widget for WordPress
@karks88
karks88 / remove_woocommerce_related_products
Last active December 13, 2019 17:31
Remove WooCommerce Related Products
@karks88
karks88 / woocommerce_add_product_message
Last active December 13, 2019 18:48
Add a message to the top of every WooCommerce product page.
<?php
// Add a message on the top of each product's page.
add_action( 'woocommerce_before_single_product', 'my_product_notice_function' );
function my_product_notice_function() { // Custom function.
echo '<p><strong>Note: Place your order by December 20 and select 1-Day shipping for guaranteed holiday delivery!</strong></p>'; // Message we're adding to the top of each product page.
}
?>
@karks88
karks88 / woocommerce_add_product_message_based_on_category
Last active December 13, 2019 18:50
Show a message based on WooCommerce product category
<?php
// Add a message on the top of each product in the "Toys" category.
add_action( 'woocommerce_before_single_product', 'my_product_notice_function' );
function my_product_notice_function() { // Custom function.
if ( is_product() && has_term( 'Toys', 'product_cat' ) ) { // Only run this code if the product is in the “Toys” category.
echo '<p><strong>Note: Place your order by December 20 and select 1-Day shipping for guaranteed holiday delivery!</strong></p>'; // Message we're adding to the top of the product page.
[
{
"key": "group_5812148bf1470",
"title": "Emergency Notice",
"fields": [
{
"key": "field_581214f410f14",
"label": "About Emergency Notices",
"name": "",
"type": "message",
<?php
// Show the Emergency Message, if it is set to "Yes".
if( get_field('show_the_emergency_notice') == 'yes' ): ?>
<div class="emergency">
<div class="emergency-inner"><?php if ( get_field('icon') ): ?><?php the_field( 'icon' ); ?><?php endif; ?> <?php the_field('emergency_notice'); ?></div>
</div>
<?php endif; // end of Emergency Message ?>
@karks88
karks88 / block-notification-bar.php
Last active May 12, 2020 17:34
A simple notification bar using the Block Lab WordPress plugin.
<div style="margin:30px auto; padding:5px 10px; background:<?php block_field( 'background-color' ); // Background Color (Color Field) ?>">
<span style="color:<?php block_field( 'text-color' ); // Text Color (Color Field) ?>"><?php block_field( 'message' ); // Message (Text Field) ?></span>
</div>
<?php
/*
Plugin Name: WooCommerce Order Surcharge
Plugin URI: https://www.karks.com
Description: Adds a flat surcharge to every order. Based on WooCommerce Snippet: https://docs.woocommerce.com/document/add-a-surcharge-to-cart-and-checkout-uses-fees-api/
Version: 1.0
Author: Eric Karkovack
Author URI: https://www.karks.com
Code culled from https://docs.woocommerce.com/document/add-a-surcharge-to-cart-and-checkout-uses-fees-api/
<?php
/*
Plugin Name: WooCommerce Order Surcharge - Percentage
Plugin URI: https://www.karks.com
Description: Adds a percentage-based surcharge to every order. Based on WooCommerce Snippet: https://docs.woocommerce.com/document/add-a-surcharge-to-cart-and-checkout-uses-fees-api/
Version: 1.0
Author: Eric Karkovack
Author URI: https://www.karks.com
*/
@karks88
karks88 / wordpress-secondary-navigation-script.php
Created July 2, 2020 19:01
This script will look at the current page and serve up a list of sibling pages.
<?php
// Show child or sibling pages in left column.
if(!$post->post_parent){
// will display the subpages of this top level page
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&sort_column=menu_order");
}
else{
if($post->ancestors) {
// now you can get the the top ID of this page