Skip to content

Instantly share code, notes, and snippets.

View kabbo508's full-sized avatar

Sumon Rahman Kabbo kabbo508

View GitHub Profile
@kabbo508
kabbo508 / functions.php (Implementing WooCommerce Shop Page Quantity Input and Plus (+) Minus (-) Button with simple Code)
Last active June 13, 2023 06:42
functions.php (Implementing WooCommerce Shop Page Quantity Input and Plus (+) Minus (-) Button with simple Code)
/*
Add Quantity Option to WooCommerce Shop Page
@ code from https://code.mukto.info
*/
add_filter( 'woocommerce_loop_add_to_cart_link', 'mukto_qty_inputs_add_to_cart', 10, 2 );
function mukto_qty_inputs_add_to_cart( $html, $product ) {
if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
$html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';
$html .= woocommerce_quantity_input( array(), $product, false );
$html .= '<button type="submit" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>';
@kabbo508
kabbo508 / jQuery code for increment or reduction by “+”, ” -” button click
Last active June 13, 2023 06:43
jQuery code for increment or reduction by “+”, ” -” button click
/*
Jquery for for Quantity Plus-Minus Button
@ code from https://code.mukto.info
*/
add_action( 'wp_footer', 'mukto_add_cart_quantity_plus_minus' );
function mukto_add_cart_quantity_plus_minus() {
wc_enqueue_js( "
$(document).on( 'click', 'button.plus, button.minus', function() {
@kabbo508
kabbo508 / Add Quantity Plus-Minus Button to the Quantity field
Last active June 13, 2023 06:43
Add Quantity Plus-Minus Button to the Quantity field
// Add Quantity Plus-Minus Button to WooCommerce Quantity Input
add_action( 'woocommerce_after_quantity_input_field', 'mukto_display_quantity_plus' );
function mukto_display_quantity_plus() {
echo '<button type="button" class="plus">+</button>';
}
add_action( 'woocommerce_before_quantity_input_field', 'mukto_display_quantity_minus' );
function mukto_display_quantity_minus() {
echo '<button type="button" class="minus">-</button>';
}
@kabbo508
kabbo508 / Add Quantity Field to WooCommerce Shop page
Last active June 13, 2023 06:37
Implementing WooCommerce Shop Page Quantity Input and Plus (+) Minus (-) Button with simple Code
/*
Add Quantity Option to WooCommerce Shop Page
@ code from https://code.mukto.info
*/
add_filter( 'woocommerce_loop_add_to_cart_link', 'mukto_qty_inputs_add_to_cart', 10, 2 );
function mukto_qty_inputs_add_to_cart( $html, $product ) {
if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
$html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';
$html .= woocommerce_quantity_input( array(), $product, false );
$html .= '<button type="submit" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>';
@kabbo508
kabbo508 / offsetting an html anchor to adjust for fixed header
Last active December 30, 2020 22:33
offsetting an html anchor to adjust for fixed header (*** WORKED - PROVED***)
(function($, window) {
var adjustAnchor = function() {
var $anchor = $(':target'),
fixedElementHeight = 120;
if ($anchor.length > 0) {
$('html, body')
.stop()
/*!
* Webflow: Front-end site library
* @license MIT
* Inline scripts may access the api using an async handler:
* var Webflow = Webflow || [];
* Webflow.push(readyFunction);
*/
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
//** * Enable preview / thumbnail for webp image files.*/
function webp_is_displayable($result, $path) {
if ($result === false) {
$displayable_image_types = array( IMAGETYPE_WEBP );
$info = @getimagesize( $path );
if (empty($info)) {
$result = false;
} elseif (!in_array($info[2], $displayable_image_types)) {
$result = false;
//** *Enable upload for webp image files.*/
function webp_upload_mimes($existing_mimes) {
$existing_mimes['webp'] = 'image/webp';
return $existing_mimes;
}
add_filter('mime_types', 'webp_upload_mimes');
@kabbo508
kabbo508 / How to make Single Product pages for WooCommerce full width (in Divi, or any theme)
Last active July 18, 2020 21:16
How to make Single Product pages for WooCommerce full width (in Divi, or any theme)
/*** Take out the divider line between content and sidebar for Single WooCommerce Product Pages ***/
.single-product #main-content .container:before {background: none;}
/*** Hide Sidebar for Single WooCommerce Product Pages ***/
.single-product #sidebar, .single-product #sidebar-secondary {display:none;}
/*** Expand the content area to fullwidth for Single WooCommerce Product Pages ***/
@media (min-width: 981px){
.single-product #left-area, .single-product #primary {
width: 100%;
@kabbo508
kabbo508 / Woocommerce Change Variable" Select Option " text
Created March 27, 2018 22:03
Please put this Script at the your Child Theme function.php file before the " } " symbol at the bottom.
add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' );
/**
* custom_woocommerce_template_loop_add_to_cart
*/
function custom_woocommerce_product_add_to_cart_text() {
global $product;
$product_type = $product->product_type;
switch ( $product_type ) {