Skip to content

Instantly share code, notes, and snippets.

View rdhimanam's full-sized avatar

Rupak Dhiman rdhimanam

View GitHub Profile
@rdhimanam
rdhimanam / prices-including-tax.php
Created January 4, 2022 17:51
Fix prices for products including tax
function monsterinsights_attach_tax_details( $body ){
if ( ! empty( $body ) && is_array( $body ) && array_key_exists( 'ea', $body ) && $body['ea'] === 'Completed Checkout' ) {
if ( class_exists( 'WooCommerce' ) && function_exists( 'wc_get_order' ) ) {
$order = wc_get_order( $body['el'] );
$items = $order->get_items();
@rdhimanam
rdhimanam / replace-id-with-sku.php
Last active November 11, 2021 05:32
Send SKU instead of product ID for orders
function monsterinsights_custom_use_sku_instead_of_id( $body ) {
$numbers = array();
foreach ( $body as $key => $value ) {
if ( 0 === strpos( $key, 'pr' ) ) {
if ( preg_match( '/\d+/', $key, $matches ) ) {
if ( isset( $matches[0] ) ) {
$numbers[] = $matches[0];
}
@rdhimanam
rdhimanam / monsterinsights-ssa-track-bookings.php
Created August 20, 2021 18:53
Track Bookings - Simply Schedule Appointments Plugin
function monsterinsights_ssa_track_successfully_booked_appointments( $appointment_id, $data, $data_before, $response ) {
if ( ! function_exists( 'ssa' ) ) {
return;
}
if ( empty( $data['status'] ) || $data['status'] !== 'booked' ) {
return;
}
@rdhimanam
rdhimanam / monsterinsights-passster-track-incorrect-code.js
Last active August 20, 2021 18:52
Track Incorrect Code - Passter
jQuery( 'document' ).ready( function( $ ){
$('.passster-submit').on('click', function(e){
ps_id = $(this).attr('data-psid');
input = $( "#" + ps_id + ' .passster-password').val();
var form = $(this).parent().parent();
let error = form.find( '.passster-error' ).text();
@rdhimanam
rdhimanam / monsterinsights-passster-track-success-code.php
Last active August 20, 2021 18:52
Track correct code for Passster
function monsterinsights_passter_track_correct_code( $input ) {
// Check if Passster is active.
if ( ! function_exists( 'ps_fs' ) ) {
return;
}
if ( ! function_exists( 'monsterinsights_mp_track_event_call' ) ) {
return;
}
@rdhimanam
rdhimanam / monsterinsights-add-custom-dimensions-via-filter.php
Last active May 15, 2023 15:53
Add custom dimensions to admin list and frontend values
/**
* This would add custom dimension to the admin list inside settings.
*/
function monsterinsights_add_dimensions_to_admin_list( $dimensions ) {
// Add dimension to array with a unique key 'services'
$dimensions['services'] = array(
'title' => __( 'Services', 'monsterinsights-dimensions' ), // Label
'label' => __( 'Services', 'monsterinsights-dimensions' ), // Description
'enabled' => true,