How to Include WPCargo Template Styles and Script to Public Pages
Shipping Rate Get Quote Template
This can be used when including WPCargo shortcodes to tabs elements in elementor. By default, WPCargo script and styles are being dequeued by some page builders and extensions. You can use the following code to include the styles and scripts used in WPCargo shortcode.
The example below is specific for the Shipping Rate Get Quote Template.
Include Styles
Copy and paste the following code to your current theme’s function.php
add_action( 'wp_head', function(){ wp_enqueue_style( 'wpcsr-public', WPCSR_URL . 'assets/css/style.css', WPCSR_VERSION ); // This is the template path of the styles });
Include Script
- Copy and paste the following code in your current theme function.php.
-
function wpc_addscript_to_tab_shortcode( $atts ) { global $post, $wpcargo; wp_enqueue_style( 'jquery-ui-styles', WPCSR_URL . 'assets/css/jquery-ui.min.css', array(), WPCSR_VERSION ); wp_enqueue_style( 'wpcsr-datetime-styles', WPCSR_URL . 'assets/css/jquery.datetimepicker.min.css', array(), WPCSR_VERSION ); wp_enqueue_style( 'wpcsr-card-styles', WPCSR_URL . 'assets/css/card.min.css', WPCSR_VERSION ); wp_enqueue_style( 'wpcsr-banner-styles', WPCSR_URL . 'assets/css/banner-style.css', WPCSR_VERSION ); wp_enqueue_style( 'wpcsr-styles', WPCSR_URL . 'assets/css/style.css', WPCSR_VERSION ); wp_enqueue_style( 'wpcsr-select2-styles', WPCFE_URL . 'assets/css/select2.min.css', WPCSR_VERSION ); // Scripts // Register script select2 from FM wp_register_script( 'wpcsr-select2-scripts', WPCFE_URL. 'assets/js/select2.min.js', array( 'jquery' ), WPCSR_VERSION, true ); wp_register_script( 'wpcsr-repeater-scripts', WPCSR_URL. 'assets/js/jquery.repeater.js', array( 'jquery' ), WPCSR_VERSION, true ); wp_register_script( 'wpcsr-datetime-scripts', WPCSR_URL. 'assets/js/jquery.datetimepicker.min.js', array( 'jquery' ), WPCSR_VERSION, true ); wp_register_script( 'wpcsr-scripts', WPCSR_URL. 'assets/js/jquery.js', array( 'jquery', 'jquery-ui-autocomplete', 'wpcsr-datetime-scripts' ), WPCSR_VERSION, true ); wp_register_script( 'wpcsr-custom-script', WPCSR_URL . 'assets/js/custom.repeater.js', array( 'jquery' ), WPCSR_VERSION, true ); wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'jquery-ui-autocomplete' ); wp_enqueue_script( 'wpcsr-select2-scripts' ); wp_enqueue_script( 'wpcsr-repeater-scripts' ); wp_enqueue_script('wpcsr-custom-script'); wp_enqueue_script('wpcsr-scripts'); $wpcsrate = isset($_GET['wpcsrate']) ? $_GET['wpcsrate'] : 1 ; $dashboardURL = get_permalink().'?acccreated=true&wpcsrate='.$wpcsrate; $timeFormat = wpcsr_is_wpcargo_exist()? $wpcargo->time_format() : 'H:i a'; $date_format = wpcsr_is_wpcargo_exist()? $wpcargo->date_format() : 'Y-m-d'; $translations = array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'formSubmitError' => __( 'Something went wrong during process, Please try agian later.', 'wpcargo-shipment-rate' ), 'dashboardURL' => $dashboardURL, 'deleteMessage' => __( 'Are you sure you want to Delete Address?', 'wpcargo-shipment-rate' ), 'errorEmailExist' => __('Email already Exist.', 'wpcargo-shipment-rate'), 'errorInCorrectEmail' => __('Incorrent Email Format.', 'wpcargo-shipment-rate'), 'errorPasswordlength' => __('Password must at least 6 Characters.', 'wpcargo-shipment-rate'), 'errorPasswordNotMatch' => __('Password NOT matched.', 'wpcargo-shipment-rate'), 'confirmDeleteRepeater' => __( 'Are you sure you want to delete this Parcel?', 'wpcargo-shipment-rate' ), 'searchShipperTitle' => __( 'Select Shipper', 'wpcargo-shipment-rate' ), 'searchReceiverTitle' => __( 'Select Receiver', 'wpcargo-shipment-rate' ), 'usernameLabel' => __('Username', 'wpcargo-shipment-rate'), 'passwordLabel' => __('Password', 'wpcargo-shipment-rate'), 'pickupRateLabel' => __('Pickup Rate', 'wpcargo-shipment-rate'), 'taxPercentage' => $wpcargo->tax, 'urlField' => wpcsr_get_url_field_meta(), 'pickupLabel' => wpcsr_pickup_label(), 'dropOffLabel' => wpcsr_dropoff_label(), 'pickupZone' => get_wpcsr_pickup_rates_column('zone'), 'referenceZone' => wpcsr_pickup_reference(), 'rateURL' => '', 'is_dashboard' => $is_dashboard, 'timeFormat' => $timeFormat, 'dateFormat' => $date_format, 'currenySymbol' => wpcsr_currency() ); wp_localize_script( 'wpcsr-scripts', 'WPCSRAjaxHandler', $translations ); } add_shortcode( 'wpcargo_shortcode_script', 'wpc_addscript_to_tab_shortcode');
-
- Paste this shortcode [wpcargo_shortcode_script] below the shipping rate template shortcode. Please see image below