Skip to content

Instantly share code, notes, and snippets.

@Acephalia
Acephalia / wcesr.php
Created July 8, 2024 13:39
Extend WooCommerce search results to include tags, descriptions and price
/*
* @snippet Extend WooCommerce search to include tags, descriptions and price
* @author u/acephaliax
* @source https://insomniainc.com/resources/code-snippets/woocommerce/how-to-extend-woocommerce-search-results-to-show-product-tags-descriptions-sku-and-price/
* @compatibility Last tested on WooCommerce 9.0.1
* @community r/wordpress, r/woocommerce
* @caffeinate https://buymeacoffee.com/acephaliax
*/
@Acephalia
Acephalia / wcvsosp.php
Created July 4, 2024 09:54
Woocommerce Variation Selectors & Add To Cart Button For Variable Products On Shop Pages
/*
* @snippet Display Variation Selectors & Add To Cart Button For Variable Products On Woocommerce Shop Pages
* @author u/acephaliax
* @source https://insomniainc.com/resources/uncategorized/variation-selectors-add-to-cart-button-for-variable-products-on-woocommerce-shop-pages/
* @compatibility Last tested on WooCommerce 9.0.1
* @community r/wordpress, r/woocommerce
* @caffeinate https://buymeacoffee.com/acephaliax
*/
// Enqueue necessary scripts for shop and archive pages
@Acephalia
Acephalia / wcldspocp.php
Created June 29, 2024 11:05
Show WooCommerce Price on LearnDash Course Page
/*
* @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
*/
@Acephalia
Acephalia / wctsdsl.php
Last active June 21, 2024 11:59
Display and Truncate Woocomemrce Short Description On Shop And Archive Loops
/*
* @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
*/
@Acephalia
Acephalia / wcbpiwt.php
Created June 15, 2024 23:54
WooCommerce Blur Product Images With Tag + Enable or Disable In My Account
/*
* @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
*/
@Acephalia
Acephalia / wcppr.php
Last active June 13, 2024 23:36
WooCommerce Redirect Thank You Page Based On Order Status
/*
* @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
*/
@Acephalia
Acephalia / sqmfdt.js
Last active June 8, 2024 14:23
Strip Make.com Quotation Marks From Divi Titles
//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, '');
}
@Acephalia
Acephalia / wcb3g1fv.php
Last active June 7, 2024 15:00
WooCommerce Buy 3 get 1 Free For Variations/Attributes
/**
* @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
@Acephalia
Acephalia / wpdvc.css
Created June 4, 2024 00:48
Divi Vertical Centre Section, Row or Module
/* 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;
}
@Acephalia
Acephalia / wchacbfnliu.php
Created April 21, 2024 10:15
Woocommerce hide add to cart button for non logged in users but show stock.
//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>