Skip to content

Instantly share code, notes, and snippets.

View harsh8511's full-sized avatar
💭
I may be slow to respond.

Harshal harsh8511

💭
I may be slow to respond.
View GitHub Profile
@harsh8511
harsh8511 / aaptc_add_product_to_cart.php
Created January 26, 2021 05:43 — forked from kartikparmar/aaptc_add_product_to_cart.php
Adding product to cart based on cart total
<?php
/*
* Automatically adding the product to the cart when cart total amount reach to $500.
*/
function aapc_add_product_to_cart() {
global $woocommerce;
$cart_total = 500;
@harsh8511
harsh8511 / functions.php
Created January 26, 2021 05:43 — forked from kartikparmar/functions.php
Adding free product to cart when a product is added to cart has category A or B or C
<?php
/**
* Automatically adding the product to the cart.
*/
function aaptc_add_product_to_cart( $item_key, $product_id ) {
$product_category_id = array( 16, 17, 18 ); // Category ids of A, B and C
$product_cats_ids = wc_get_product_term_ids( $product_id, 'product_cat' );
$product_category_id_check = false;