Skip to content

Instantly share code, notes, and snippets.

View rajeshsingh520's full-sized avatar

Rajesh rajeshsingh520

View GitHub Profile
@rajeshsingh520
rajeshsingh520 / shipping-description.php
Created May 3, 2024 07:59
show description in () below the dropdown
add_action('wp_enqueue_scripts', function(){
$js = '
function set_message(){
if(jQuery("#shipping_method_msg").length < 1){
jQuery("#shipping_method_0").after("<div id=\"selected_method_msg\"></div>");
}
var selectedOption = jQuery("#shipping_method_0").children("option:selected").text();
add_filter( 'woocommerce_package_rates', function ( $rates, $package ) {
foreach ( $rates as $rate_key => $rate ) {
$rounded_cost = round( $rate->cost );
$rates[$rate_key]->cost = $rounded_cost;
}
return $rates;
}, PHP_INT_MAX, 2 );
class pisol_custom_code_20240429{
static $instance = null;
static function get_instance(){
if(is_null(self::$instance)){
self::$instance = new self();
}
return self::$instance;
}
function register_custom_post_type_pi_shipping_method() {
$args = array(
'public' => true,
'label' => 'Shipping Methods',
'supports' => array( 'title', 'editor' ),
'show_in_menu' => false // This option hides the post type from the admin menu
);
register_post_type( 'pi_shipping_method', $args );
}
add_action( 'init', 'register_custom_post_type_pi_shipping_method' );
add_action('wp_enqueue_scripts', function(){
$inline_script = "
jQuery(document).ready(function($){
jQuery(document).ajaxComplete(function(event, jqxhr, settings){
var ajax_link = settings.url;
if (ajax_link && ajax_link != 'undefined' && ajax_link.search(/nm-ajax-add-to-cart/i) >= 0) {
var searchParams = new URLSearchParams(settings.data);
var postDataObj = {};
class pisol_specail_date_for_category{
static $special_date = ['2024/05/10', '2024/05/11', '2024/05/12'];
static $special_category = 44;
static $instance = null;
static function get_instance(){
if(is_null(self::$instance)){
self::$instance = new self();
}
add_filter('pisol_dtt_disable_shipping_method_filter', function($disable){
if(isset($_POST['action']) && $_POST['action'] == 'phone-orders-for-woocommerce') return true;
return $disable;
});
class pisol_custom_clone_checkbox{
static $instance = null;
static $run = 0;
static function get_instance(){
if(is_null(self::$instance)){
self::$instance = new self();
}
add_action('pisol_eqw_enquiry_saved', function($enq_id){
$meta_data = get_post_meta($enq_id);
foreach ($meta_data as $key => $values) {
// Check if the value is an array and has at least one element
if (is_array($values) && count($values) > 0) {
// Assign the first value directly to a variable with the meta key as the variable name
$meta_data[$key] = $values[0];
}
}
add_action('wp_loaded', function(){
$dates = custom_get_dates_20240323(378);
error_log(print_r($dates, true));
});
function custom_get_dates_20240323($location_id){
if(isset(WC()->session) && is_object(WC()->session) && class_exists('pi_dtt_js')){
$old_location = WC()->session->get("pickup_location");
WC()->session->set("pickup_location", $location_id);
$dates = pi_dtt_js::allowedDates();