Skip to content

Instantly share code, notes, and snippets.

@helpercode0
helpercode0 / functions.php
Last active December 22, 2024 17:13
Add Field in Checkout Woocommerce Block Programmatically
add_action(
'woocommerce_init',
function() {
woocommerce_register_additional_checkout_field(
array(
'id' => 'namespace/delivery-date-id',
'label' => 'Delivery Date',
'optionalLabel' => 'Delivery Date (optional)',
'location' => 'address',
'required' => true,
@helpercode0
helpercode0 / liquid or js file
Created August 12, 2024 17:53
Clear Cart on Page Load Shopify
<script>
/**
* Clears the cart in Shopify and logs the result or errors.
*/
function clearCart() {
fetch('/cart/clear.js', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
@helpercode0
helpercode0 / index.html
Created August 12, 2024 17:41
Adavance BMI calculator javascript, html and css
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BMI Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
@helpercode0
helpercode0 / functions.php
Last active August 12, 2024 17:25
Include Exclude Tax Toogle For Woocommerce
<?php
function kl_tax_toggle_shortcode() {
$kl_show_tax = isset($_COOKIE['kl_show_tax']) ? $_COOKIE['kl_show_tax'] : 'yes';
ob_start();
?>
<div class="kl-tax-toggle-wrapper">
@helpercode0
helpercode0 / gist:eabbfa64b6b0712ba3a41aef85163b4e
Last active September 27, 2022 15:25
How to setup wordpress default featured image
<?php
add_filter( 'get_post_metadata', 'WDFI_get_post_metadata', 50, 10);
function WDFI_get_post_metadata($null, $object_id, $meta_key, $single ){
if ( ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) ) {
return $null;
}
if ( ! empty( $meta_key ) && '_thumbnail_id' !== $meta_key ) {
return $null;
}
$post_type = get_post_type( $object_id );
<?php
/**
* WooCommerce Extra Feature
* --------------------------
*
* Add custom fee to cart automatically
*
*/
function woo_add_cart_fee() {