Skip to content

Instantly share code, notes, and snippets.

View zakirsajib's full-sized avatar
💭
Looking for a new challenge in 2022!

Zakir Sajib zakirsajib

💭
Looking for a new challenge in 2022!
View GitHub Profile
add_action('gform_after_submission', 'add_product_to_cart_and_checkout', 10, 2);
function add_product_to_cart_and_checkout($entry, $form) {
// Product mapping array
$product_mapping = array(
'Mycotoxin Panel' => 373340
);
// Replace '4' with the ID of your Gravity Form
if ($form['id'] == 30) {
// Get selected product name from dropdown field ID 12
if ( $F4 == '<img src="https://aspenhr.com/wp-content/uploads/2024/02/noto-desktop-computer.svg" alt="White Collar" title="White Collar">White Collar' ):
if($F7 == 'Alabama'):
$F1 + $F2 + ( $F1 * ($F3/100) ) + ($F1 * .0765) + (.028 * 8000 ) + 420 + ($F1 * .002) + $F10
elseif($F7 == 'Alaska'):
$F1 + $F2 + ( $F1 * ($F3/100) ) + ($F1 * .0765) + (.032 * 48600 ) + 420 + ($F1 * .002) + $F10
elseif($F7 == 'Arizona'):
$F1 + $F2 + ( $F1 * ($F3/100) ) + ($F1 * .0765) + (.094 * 8000 ) + 420 + ($F1 * .002) + $F10
elseif($F7 == 'Arkansas'):
$F1 + $F2 + ( $F1 * ($F3/100) ) + ($F1 * .0765) + (.072 * 7000 ) + 420 + ($F1 * .002) + $F10
elseif($F7 == 'California'):
/**
* Applies a combo discount when specific products are in the cart.
*
* This function checks if two or more products with the specified product IDs are in the cart.
* If both products are present, a discount is applied as a negative fee.
*
* @param WC_Cart $cart The WooCommerce cart instance.
*/
function apply_discount_on_combo( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
@zakirsajib
zakirsajib / index.js
Last active April 21, 2023 10:05
Connect Wix form to Hubspot form
/*
# Overview
This code connects a contact form on a Wix site to a HubSpot portal, so that form submissions are automatically synced to HubSpot as new contacts.
# Prerequisites
Before using this code, you'll need:
1. A Wix site with a contact form
2. A HubSpot account with a portal ID and form GUID
@zakirsajib
zakirsajib / background.txt
Last active March 5, 2023 16:55
Create option page. Let's say we have ACF gallery field. Users from their profile can upload as many images as they want to add into gallery from frontend. When they upload it saves into their user profile. And in another page say photo album will show all images from each gallery of each user. But admin of the site wants to control which image …
/**
Background:
Let's say we have ACF gallery field 'gallery_by_parents'. Users can upload as many images as they want to add into gallery from frontend.
When they upload it saves into their user profile in wp dashboard.
And in another page say photo album will show all images from each gallery of each user.
But admin of the site wants to control which image should appear in photo album page.
So we will create an option page where it will show a table, where user and their all images of gallery will be displayed.
And then we will add a checkbox beside of each image.
When admin will select the checkbox then associate image of that checkbox will be saved into option table into db.
@zakirsajib
zakirsajib / gist:996e6722900552ccd81ec89839700842
Last active December 7, 2022 14:14
Shopify liquid code to split your description/content into two blocks.
<div class="collection_header_block">
{{ collection.description | split: '---' | first }}
</div>
<div class="collection_footer_block">
{{ collection. description | split: '---' | last }}
</div>
@zakirsajib
zakirsajib / single-product-layout-type-1.liquid
Last active September 7, 2022 21:34
How to copy payment image from footer to product single page in shopify.
# First copy this code from footer.liquid file
<img src="{{ 'payment.png' | asset_url }}" alt="Payment" />
and then go to `snippets` and find the `single-product-layout-type-1.liquid` file
And go to line #250
and add the code:
@zakirsajib
zakirsajib / function.php
Last active September 7, 2022 16:12
Adding User Details before billing details in checkout page in Woocommerce
add_action( 'woocommerce_checkout_before_customer_details', 'superdville_checkout_fields_before_billing_details', 20 );
function superdville_checkout_fields_before_billing_details(){
$domain = 'superDville';
$checkout = WC()->checkout;
echo '<div class="col2-set" id="superdville_custom_checkout_field">';
echo '<div class="col-1">';
echo '<h3>' . __('User Details') . '</h3>';
woocommerce_form_field( 'your_role', array(
@zakirsajib
zakirsajib / function.php
Created September 7, 2022 16:08
Change the default country on the checkout page: Woocommerce
add_filter( 'default_checkout_billing_country', 'change_default_checkout_country' );
function change_default_checkout_country() {
if ( WC()->customer->get_is_paying_customer() ) {
return $country;
}
return 'US';
}
@zakirsajib
zakirsajib / src@components@header.js
Created May 31, 2022 16:50
Dark Mode implementation in Mars theme of Frontity App
import { connect, styled, Global, css } from "frontity";
import Link from "./link";
import Nav from "./nav";
import NavTabletMobile from "./nav-mobile";
import MobileMenu from "./menu";
import SearchForm from "./search/search-form";
import LogoDark from '../../img/nirvana.jpg';
import JoinMobile from '../../img/join-mobile.svg';
import Toggle from "./toggle";