Skip to content

Instantly share code, notes, and snippets.

View mohsendro's full-sized avatar
🏠
Working from home

Mohsendro mohsendro

🏠
Working from home
View GitHub Profile
@mohsendro
mohsendro / cheatsheet.md
Created July 16, 2025 06:39 — forked from lucasKoyama/cheatsheet.md
Next.js 14 CheatSheet
@mohsendro
mohsendro / wcvsosp.php
Created February 11, 2025 22:08 — forked from Acephalia/wcvsosp.php
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
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );
@mohsendro
mohsendro / woo-events.js
Created January 7, 2025 12:27 — forked from bagerathan/woo-events.js
[Woocommerce Javascript events] #woo
//Woocommerce Checkout JS events
$( document.body ).trigger( 'init_checkout' );
$( document.body ).trigger( 'payment_method_selected' );
$( document.body ).trigger( 'update_checkout' );
$( document.body ).trigger( 'updated_checkout' );
$( document.body ).trigger( 'checkout_error' );
//Woocommerce cart page JS events
$( document.body ).trigger( 'wc_cart_emptied' );
$( document.body ).trigger( 'update_checkout' );

Woocommerce Javascript events
Woocommerce Checkout JS events

$( document.body ).trigger( 'init_checkout' );
$( document.body ).trigger( 'payment_method_selected' );
$( document.body ).trigger( 'update_checkout' );
$( document.body ).trigger( 'updated_checkout' );
$( document.body ).trigger( 'checkout_error' );
$( document.body ).trigger( 'applied_coupon_in_checkout' );
@mohsendro
mohsendro / woocommerce-ajax.php
Created March 29, 2024 22:33 — forked from qutek/woocommerce-ajax.php
[Wordpress] [Woocommerce] WooCommerce Ajax Handlers
<?php
/**
* WooCommerce Ajax Handlers
*
* Handles AJAX requests via wp_ajax hook (both admin and front-end events)
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/** Frontend AJAX events **************************************************/
@mohsendro
mohsendro / Kama_Breadcrumbs.php
Created March 23, 2024 20:20 — forked from doiftrue/Kama_Breadcrumbs.php
[wpkama embed] https://wp-kama.ru/541 Breadcrumbs for WordPress
<?php
/**
* Breadcrumbs for WordPress
*
* @param string $sep Separator. Default is ' » '.
* @param array $l10n For localization. See the variable `$default_l10n`.
* @param array $args Options. See the variable `$def_args`.
*
* @return void Outputs HTML code to the screen
@mohsendro
mohsendro / term-hierarchical-search.php
Created February 27, 2024 13:18 — forked from hellofromtonya/term-hierarchical-search.php
WordPress Term Hierarchical Search
<?php
/**
* Term Hierarchical Search
*
* These methods provide a utility interface to find a meta value
* within the term's hierarchy. It walks up the hierarchy starting
* at the given term, i.e. walks to its parent -> grandparent -> N levels.
*
* It's performant as it grabs the records it needs out of the database
* with one SQL query, i.e. to avoid multiple trips to gather each level's