Skip to content

Instantly share code, notes, and snippets.

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

Pramod Jodhani pramodjodhani

🏠
Working from home
  • 16:27 (UTC +05:30)
View GitHub Profile
@pramodjodhani
pramodjodhani / functions.php
Created December 28, 2022 06:54
auto add a product to cart if cart is empty
<?php
/**
* Flux - Auto add product to cart if cart is empty and user visits checkout page.
*
* @return void
*/
function auto_add_product_to_cart() {
if ( is_checkout() && WC()->cart->is_empty() ) {
WC()->cart->add_to_cart( 10 );
}
@pramodjodhani
pramodjodhani / flux-add-custom-code-thankyou.php
Created January 4, 2023 06:20
Flux checkout add custom code to the thank you page
<?php
/**
* Flux checkout - add custom code to the Thank you page.
*
* @return void
*/
function iconic_flux_add_custom_code_thankyou_page() {
if ( ! class_exists( 'Iconic_Flux_Core' ) || ! Iconic_Flux_Core::is_thankyou_page() ) {
return;
}
@pramodjodhani
pramodjodhani / flux-hide-field-for-digital-products.php
Last active February 1, 2023 05:59
Flux checkout - hide fields for digital products
<?php
/**
* Flux hide address.
*
* @param array $fields Fields.
*
* @return array
*/
function flux_hide_address_fields_for_digital_products( $fields ) {
@pramodjodhani
pramodjodhani / wds-function.php
Last active January 25, 2023 06:14
Conditionally change the fees label to 'Saturday Delivery Fee' when the selected day is a Saturday
<?php
/**
* Iconic WDS - update Fees description when the selected day is a Saturday.
*
* @param string $label Label.
*
* @return string
*/
function iconic_wds_update_fee( $label ) {
if ( empty( $_POST['post_data'] ) ) {
@pramodjodhani
pramodjodhani / wap-compat-divi.php
Created January 19, 2023 07:18
Iconic Account Pages compatibility with Divi Builder
<?php
/**
* Iconic Account Pages - compatiblity with Divi builder.
*
* @param WP_Query $q Query.
*
* @return void
*/
function iconic_wap_divi_compatibility( $q ) {
if ( empty( $_GET['et_fb'] ) ) {
@pramodjodhani
pramodjodhani / hide-timeslot-for-collection.php
Last active January 21, 2025 09:14
WDS - hide timeslot for collection shipping method
<?php
add_action( 'wp_footer', function () { ?>
<script>
jQuery( document.body ).on( 'updated_checkout', iconic_wds_toggle_timeslot );
jQuery( document ).ready( iconic_wds_toggle_timeslot );
function iconic_wds_toggle_timeslot() {
var selected_shipping_method = jQuery( "#shipping_method :radio:checked" ).val();
if ( !selected_shipping_method ) {
@pramodjodhani
pramodjodhani / wds-compat-gpay-apple.php
Last active October 25, 2023 07:14
WDS - compatiblity with stripe Gpay and apple pay
<?php
/**
* Iconic WDS - compatibility with Stripe Gpay/Apple Pay.
* Disable WDS checks when the payment is being made from Express checkout.
*
* @return void
*/
function iconic_wds_compat_stripe_gpay() {
$wc_ajax = filter_input( INPUT_GET, 'wc-ajax' );
@pramodjodhani
pramodjodhani / flux-classic-checkbox-issue.css
Last active January 31, 2023 07:16
Flux checkout classic theme checkbox issue
p.form-row>input[type=checkbox]:before ,
p.form-row>input[type=checkbox]:after {
display: inline-block;
box-sizing:content-box;
}
p.form-row>input[type=checkbox]+label {
display: inline;
}
@pramodjodhani
pramodjodhani / flux-auto-open-order-summary-section-mobile.php
Created February 1, 2023 05:44
Flux - auto open order review section on mobile.
<?php
/**
* Flux checkout - auto open order review section.
*
* @return void
*/
function flux_auto_open_order_review_mobile() {
if ( ! is_checkout() ) {
return;
}
@pramodjodhani
pramodjodhani / wds.php
Created February 13, 2023 07:01
WDS compat divi builder/elementor builder
<?php
/**
* Iconic WDS - Fix for Divi checkout builder/Elementor builder.
* Adds shortcode [iconic_wds_fields]
* and removes the default position of delivery slots.
*
* @return void
*/
function iconic_wds_remove_default_fields_add_shortcode() {
global $iconic_wds;