Skip to content

Instantly share code, notes, and snippets.

[[[DIVSTYLE:TProw|[[[DIVSTYLE:TPcol-sm-5;text-align:center;|[[[PIC:Vickers-logo.svg |100%|||TPlogoTop|||||]]] ]]] [[[DIVSTYLE:TPcol-sm-7 TPhidden-xs| ]]] ]]]
{
"particles": {
"number": {
"value": 400,
"density": {
"enable": true,
"value_area": 800
}
},
"color": {
@infocities
infocities / wp5.3-boostrap4.4-collapse-navwalker.php
Created August 12, 2021 16:48 — forked from mtx-z/wp5.3-boostrap4.4-collapse-navwalker.php
Wordpress 5.3 NavWalker with Bootstrap 4.4 collapse with correct parent ".collapsed" class and ".active" classes (custom Wordpress nav walker class + example)
<?php
/**
* Class Name: Bootstrap_Collapse_NavWalker
* GitHub URI: https://gist.github.com/mtx-z/db34d68364108c0285e6e3e721630846
* Description: A custom WordPress 5.3 nav walker class for Bootstrap 4.4 nav menus in a custom theme using the WordPress built in menu manager
* Version: 0.1
* Author: Mtxz
* Source: https://github.com/filipszczepanski/wp-bootstrap4-collapse-navwalker
* Tested only with 1 sublevel, but should work with as many level as you want
@infocities
infocities / wp-woocommerce-edit-product-loop-thumbnail-template.php
Created August 12, 2021 16:49 — forked from mtx-z/wp-woocommerce-edit-product-loop-thumbnail-template.php
Woocommerce (3.8.1) edit product loop thumbnail template (allows to had/edit HTML outputted by Woocommerce to generate the product loop thumbnail image area, as there is no dedicated template file to override) - Wordpress 5.5.1 / Woocommerce 3.8.1
<?php
/**
* Edit default Woocommerce product loop thumbnail template
* As there is no dedicated Woocommerce template (eg wp-content/plugins/woocommerce/templates/loop/price.php)
* because it's generated using filter, we must remove Woocommerce hook, and add our own "at the same place"
* to edit the product loop thumbnail template
* tested up to (12/10/2020) :
* Wordpress 5.7
* Woocommerce 3.8.1
* PHP 7.3.7
@infocities
infocities / attributes-as-options.php
Created August 12, 2021 16:49 — 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();
@infocities
infocities / wp-woocommerce-checkout-form-bootstrap4.4.php
Created August 16, 2021 08:33 — forked from mtx-z/wp-woocommerce-checkout-form-bootstrap4.4.php
Add bootstrap 4.4 styling to Woocommerce checkout shipping and billing form
<?php
/**
* Edit checkout form inputs
* source: https://gist.github.com/nickkuijpers/5d07ecf9b0a0678b4f4c
*/
add_filter('woocommerce_checkout_fields', 'addBootstrapToCheckoutFields' );
/**
* @param $fields
* @return mixed
*/
@infocities
infocities / woocommerce-sage-template-part-overrides.md
Created August 16, 2021 08:39 — forked from drawcard/woocommerce-sage-template-part-overrides.md
Woocommerce - Using template part overrides in Sage

So, you know how to override a template file in Woocommerce using Sage, but you're having trouble changing something within the deeper level of that template file. For example, you want to change the output HTML structure of a given part of the product page loop, or incorporate a Bootstrap class into a button element without using Jquery to inject it. Here's how you can override deeper level parts, the default WC theme elements.

Prerequisites

Now you're familiar with how to do Sage + Woocommerce templates, it's time to make it happen.

The template page override

@infocities
infocities / functions.php
Created August 25, 2021 20:45 — forked from jameskoster/functions.php
WooCommerce - change number of products displayed per page
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value stored on Options -> Reading
// Return the number of products you wanna show per page.
$cols = 9;
return $cols;
}
@infocities
infocities / wc_ajax_add_to_cart.php
Created August 25, 2021 20:47 — forked from elalexoh/wc_ajax_add_to_cart.php
Woocommerce Ajax Add To Cart Button
<?php
//AJAX ADD TO CART BUTTON
$product_id = 143;
if( !my_custom_cart_contains( $product_id ) ) {
?>
<button class="my-custom-add-to-cart-button" data-product-id="<?php echo $product_id; ?>">add to cart</button>
<?php
} else {
?>