Skip to content

Instantly share code, notes, and snippets.

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

Pramod Jodhani pramodjodhani

🏠
Working from home
  • 10:53 (UTC +05:30)
View GitHub Profile
@pramodjodhani
pramodjodhani / wds.php
Last active November 14, 2024 11:55
Iconic WDS - Dynamically update the fee based on the current day and same day
<?php
add_action( 'woocommerce_cart_calculate_fees', 'iconic_wds_dynamically_add_custom_fee', 9 );
function iconic_wds_dynamically_add_custom_fee() {
global $iconic_wds;
if ( empty( $iconic_wds ) ) {
return;
}
$chosen_method = $iconic_wds->get_chosen_shipping_method();
@pramodjodhani
pramodjodhani / flux.php
Created November 6, 2024 06:05
flux - display express checkout options on all the pages
/**
* Flux checkout - Move the express checkout button so that it is displayed on all the steps.
*
* @return void
*/
function iconic_flux_move_express_checkout_button() {
remove_action( 'woocommerce_checkout_before_customer_details', array( 'Iconic_Flux_Core', 'express_checkout_button_wrap' ) );
add_action( 'flux_after_header', array( 'Iconic_Flux_Core', 'express_checkout_button_wrap' ) );
}
add_action( 'init', 'iconic_flux_move_express_checkout_button' );
@pramodjodhani
pramodjodhani / flux.php
Created November 6, 2024 06:04
Flux Woo Subscription - disable create account/password for known users.
/**
* Flux checkout - remove password field.
*/
function iconic_flux_remove_pass_field( $fields ) {
unset( $fields['account']['account_password'] );
return $fields;
}
add_filter( 'woocommerce_checkout_fields', 'iconic_flux_remove_pass_field', 9999 );
/**
@pramodjodhani
pramodjodhani / functions.php
Last active October 30, 2024 16:25
Flux checkout - Move the express checkout button so that it is displayed on all the steps.
<?php
/**
* Flux checkout - Move the express checkout button so that it is displayed on all the steps.
*
* @return void
*/
function iconic_flux_move_express_checkout_button() {
remove_action( 'woocommerce_checkout_before_customer_details', array( 'Iconic_Flux_Core', 'express_checkout_button_wrap' ) );
add_action( 'flux_after_header', array( 'Iconic_Flux_Core', 'express_checkout_button_wrap' ) );
}
@pramodjodhani
pramodjodhani / functions.php
Created October 29, 2024 09:31
Add CNY currency to Gravity Form
<?php
add_filter( 'gform_currencies', 'idea_mcg_add_cny_currency' );
function idea_mcg_add_cny_currency( $currencies ) {
$currencies['CNY'] = array(
'name' => 'Chinese Yuan',
'code' => 'CNY',
'symbol_left' => 'CNY ',
'symbol_right' => '',
'symbol_padding' => ' ',
'thousand_separator' => ',',
@pramodjodhani
pramodjodhani / file.json
Created October 28, 2024 12:03
Stripe sample webhook for `payment_intent.created` event
{
"id": "evt_3QEreVLiNMWTEN8V0ptqNrBw",
"object": "event",
"api_version": "2024-04-10",
"created": 1730116951,
"data": {
"object": {
"id": "pi_3QEreVLiNMWTEN8V07kTvLbJ",
"object": "payment_intent",
"amount": 4500,
@pramodjodhani
pramodjodhani / functions.php
Created October 24, 2024 07:09
Flux checkout - Disable auto placeholder for phone number field.
/**
* Flux checkout - Disable auto placeholder for phone number field.
*
* @return void
*/
function flux_checkout_intl_phone_args() {
?>
<script>
wp.hooks.addFilter( 'flux_checkout_intl_phone_args', 'flux_checkout', function( args ) {
args.autoPlaceholder = 'off';
@pramodjodhani
pramodjodhani / functions.php
Created September 20, 2024 07:13
Include the value of CFFV field in the order.
/**
* Iconic CFFV - Get the location custom field value.
*
* @param int $variation_id
*
* @return string|bool
*/
function iconic_cffv_get_location( $variation_id ) {
if ( empty( $variation_id ) ) {
return false;
@pramodjodhani
pramodjodhani / functions.php
Created September 18, 2024 16:38
Add TRY (Turkish Lira) currency to Gravity Forms.
/**
* Add TRY (Turkish Lira) currency to Gravity Forms.
*
* @param array $currencies The current currencies registered in Gravity Forms.
*
* @return array List of supported currencies.
*/
function add_try_currency( $currencies ) {
$currencies['TRY'] = array(
'name' => 'Turkish Lira',
@pramodjodhani
pramodjodhani / functions.php
Created September 12, 2024 09:37
Iconic WDS - Add Pickup instructions above the delivery slots fields.
/**
* Iconic WDS - Add Pickup instructions above the delivery slots fields.
*/
add_filter( 'iconic_wds_after_delivery_details_title', function( $title ) {
// Todo1 - Add URL of the Pickup Instructions Page.
?>
<a href="#" id="wds-pickup-instructions">Click here to read the Pickup instructions.</a>
<?php
} );