Skip to content

Instantly share code, notes, and snippets.

View Attaulla9's full-sized avatar
💻
Focusing

Attaullla Faniband Attaulla9

💻
Focusing
View GitHub Profile
@Attaulla9
Attaulla9 / eventTracker.js
Created December 4, 2019 13:50 — forked from walkergv/eventTracker.js
Unbounce Event Tracker Script
<script type='text/javascript'>
(function() {
var EventTracker, lpScriptVersion;
lpScriptVersion = "1.2.0";
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
@Attaulla9
Attaulla9 / jQueryCheatSheet.js
Created September 13, 2020 17:07 — forked from davidmigloz/jQueryCheatSheet.js
Basic jQuery Cheat Sheet.
http://www.w3schools.com/js
http://www.w3schools.com/jquery/
http://api.jquery.com/
http://www.html5canvastutorials.com/
--> events:
$('#submit').click(function);
$("p").dblclick(function);
$("#id").change(function);
$(canvas).mousedown(function);
@Attaulla9
Attaulla9 / vanilla-js-cheatsheet.md
Created September 13, 2020 17:24 — forked from thegitfather/vanilla-js-cheatsheet.md
Vanilla JavaScript Quick Reference / Cheatsheet
@Attaulla9
Attaulla9 / zipcode.php
Last active January 8, 2021 06:25
Woocommerce zipcode validation
add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');
function my_custom_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error. This one is only requite for companies
if ( ! (preg_match('/^[0-9]{6}$/D', $_POST['billing_postcode'] ))){
wc_add_notice( "Invalid Postal Code." ,'error' );
}
}
@Attaulla9
Attaulla9 / default_country.php
Created January 8, 2021 06:35
Woocommerce make default country be selected in checkout page
// Change the default state and country on the checkout page and this code paste in function.php
add_filter( 'default_checkout_billing_country', 'bbloomer_change_default_checkout_country' );
function bbloomer_change_default_checkout_country() {
return 'IN';
}
@Attaulla9
Attaulla9 / review.php
Created January 8, 2021 06:43
Remove mandatory field comment from the review field
// removed mandatory field from the review (rating)
add_filter('allow_empty_comment', '__return_true');
@Attaulla9
Attaulla9 / flash-Sale.php
Created January 8, 2021 06:48
woocommerce Add a flash sale offer on the subtotal and show it in cart page and checkout page
// Hook before calculate fees flash sale in cart page discount
add_action('woocommerce_cart_calculate_fees' , 'add_user_discounts');
function add_user_discounts( WC_Cart $cart ){
//any of your rules
// Calculate the amount to reduce
$discount = $cart->get_subtotal();
$cart->add_fee( 'Flash Sale 20% off', -$discount / 100 * 20); //Here you can change the percentage you want to apply
@Attaulla9
Attaulla9 / hidecouponfield.php
Last active January 8, 2021 06:49
woocommerce Hide coupon field from the cart and checkout page
//hide coupon field on cart page
add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field_on_cart' );
function hide_coupon_field_on_cart( $enabled ) {
if ( is_cart() ) {
$enabled = false;
}
return $enabled;
@Attaulla9
Attaulla9 / medicalreviewdby.php
Created January 13, 2021 04:19
injecting text in blog post before and after the content ('medicalReviewedBy' is the custom field rendering before the content of the post)
function medicalReviewedBy ($content){
if(get_field('medical_reviewed_by')){
$medical_reviewed_by = get_field('medical_reviewed_by');
$before = "<p style='font-style: italic;font-weight:bold' >Medical Reviewed by <span'>" . $medical_reviewed_by . "</span></p>";
$after = "";
$content = $before . $content . $after;
}
return $content;
}
@Attaulla9
Attaulla9 / minorder_message.php
Created January 19, 2021 08:00
Show a message on cart page min order $$
//Testing the COD option
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
function wc_minimum_order_amount() {
// Set this variable to specify a minimum order value
$minimum = 500;
if ( WC()->cart->total < $minimum ) {