This file contains hidden or 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
/* | |
* @snippet Show WooCommerce Price on LearnDash Course Page | |
* @description This code retrieves the WooCommerce price associated with a LearnDash course and displays it on the course page, replacing the default "No Price" label. It also provides a shortcode to manually display the price on any page. | |
* @author u/acephaliax | |
* @source https://insomniainc.com/resources/ | |
* @compatibility Last tested on WooCommerce 9.0.1 | |
* @community r/wordpress, r/woocommerce | |
* @caffeinate https://buymeacoffee.com/acephaliax | |
*/ |
This file contains hidden or 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
/* | |
* @snippet Display and Truncate Woocomemrce Short Description On Shop And Archive Loops | |
* @description This snippet will add a product's short description to the archive and loop pages. The short description will be truncated via pure CSS and expanded on hover. | |
* @author u/acephaliax | |
* @source https://insomniainc.com/resources/ | |
* @compatibility Last tested on WooCommerce 9.0.1 | |
* @community r/wordpress, r/woocommerce | |
* @caffeinate https://buymeacoffee.com/acephaliax | |
*/ |
This file contains hidden or 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
/* | |
* @snippet WooCommerce Blur Product Images With Tag + Enable or Disable In My Account | |
* @description This snippet will redirect a user to a seperate page depending on created order status. | |
* @author u/acephaliax | |
* @source. https://insomniainc.com/resources/code-snippets/woocommerce/blur-woocommerce-product-images-my-account-page-blur-toggle/ | |
* @compatiblity Last tested on WooCommerce 8.9.2 | |
* @community r/wordpress, r/woocommerce | |
* @caffeinate https://buymeacoffee.com/acephaliax | |
*/ |
This file contains hidden or 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
/* | |
* @snippet WooCommerce Redirect Thank You Page Based On Order Status | |
* @description This snippet will redirect a user to a seperate page depending on created order status. | |
* @author u/acephaliax | |
* @source. https://gist.github.com/Acephalia/cf80e9a154cb6989590518040371c79e | |
* @compatiblity Last tested on WooCommerce 8.9.2 | |
* @community r/wordpress, r/woocommerce | |
* @caffeinate https://buymeacoffee.com/acephaliax | |
*/ |
This file contains hidden or 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
//If you'd be inclined to support the support you can caffeinate me at https://buymeacoffee.com/acephaliax | |
// Apply globally via Divi > Theme Options > Integrations > Head or via code module to both Blog and All Posts templates in theme builder. | |
<script type="text/javascript"> | |
document.addEventListener("DOMContentLoaded", function() { | |
// Remove quotation marks from the direct text content of elements with class "entry-title" | |
const titleElement = document.querySelector(".entry-title"); | |
if (titleElement) { | |
titleElement.textContent = titleElement.textContent.replace(/^“|”$/g, ''); | |
} |
This file contains hidden or 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
/** | |
* @snippet WooCommerce Buy 3 get 1 Free For Variations/Attributes | |
* @how-to https://insomniainc.com/code-snippets/woocommerce/woocommerce-buy-3-get-1-free-for-variations-attributes/ | |
* @author u/acephaliax | |
* @compatiblity Last tested on WooCommerce 8.9.2 | |
* @community r/wordpress, r/woocommerce | |
* @caffeinate https://buymeacoffee.com/acephaliax | |
*/ | |
// Hook to calculate fees in the cart |
This file contains hidden or 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
/* Vertically center rows in sections and modules in columns. Add class to Advance > CSS IDS & Classes > Class. For section : vsection | For row : vrow | for module : vmodule */ | |
.vrow .et_pb_column, | |
.vsection, | |
.vmodule { | |
display: flex; | |
flex-direction: column; | |
justify-content: center; | |
} |
This file contains hidden or 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
//Hide add to cart button for non logged in users but show stock. | |
function hide_add_to_cart_for_non_logged_in_users() { | |
if (!is_user_logged_in()) { | |
?> | |
<style> | |
form.cart { | |
display: none; | |
} | |
</style> |
This file contains hidden or 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
//Convert uploaded files to webp and delete uploaded file. Imagick needs to be enabled. This can be done via the php config settings in your servers control panel. | |
function compress_and_convert_images_to_webp($file) { | |
// Check if file type is supported | |
$supported_types = ['image/jpeg', 'image/jpg', 'image/png', 'image/webp']; | |
if (!in_array($file['type'], $supported_types)) { | |
return $file; | |
} | |
// Check if file is already a WebP image |
This file contains hidden or 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
//Don't use this it is a bad idea. This code replaces all acrhcive and shop page thumbnail links to work as add to cart urls. When clicked the item will be added to cart instead of opening the single product page. Works only for simple products (obviously). | |
function wc_custom_shop_thumbnail_link( $link, $product ) { | |
if ( $product->is_type( 'simple' ) && ( is_shop() || is_product_category() || is_product_tag() ) ) { | |
$link = '?add-to-cart='. $product->get_id(); | |
} | |
return $link; | |
} | |
add_filter( 'woocommerce_loop_product_link', 'wc_custom_shop_thumbnail_link', 10, 2 ); |