/** * Output the calendar view */ public function output() { wp_enqueue_script('chosen'); $product_filter = isset($_REQUEST['filter_bookings']) ? absint($_REQUEST['filter_bookings']) : ''; $view = isset($_REQUEST['view']) && $_REQUEST['view'] == 'day' ? 'day' : 'month'; if ($view == 'day') { $day = isset($_REQUEST['calendar_day']) ? wc_clean($_REQUEST['calendar_day']) : date('Y-m-d'); $this->bookings = WC_Bookings_Controller::get_bookings_in_date_range(strtotime('midnight', strtotime($day)), strtotime('midnight +1 day', strtotime($day)), $product_filter); } else { $month = isset($_REQUEST['calendar_month']) ? absint($_REQUEST['calendar_month']) : date('n'); $year = isset($_REQUEST['calendar_year']) ? absint($_REQUEST['calendar_year']) : date('Y'); if ($year < date('Y') - 10 || $year > 2100) { $year = date('Y'); } if ($month > 12) { $month = 1; $year++; } if ($month < 1) { $month = 1; $year--; } $start_week = (int) date('W', strtotime("first day of {$year}-{$month}")); $end_week = (int) date('W', strtotime("last day of {$year}-{$month}")); if ($end_week == 1) { $end_week = 53; } $this->bookings = WC_Bookings_Controller::get_bookings_in_date_range(strtotime($year . 'W' . str_pad($start_week, 2, '0', STR_PAD_LEFT)), strtotime($year . 'W' . str_pad($end_week + 1, 2, '0', STR_PAD_LEFT)), $product_filter); } include 'views/html-calendar-' . $view . '.php'; wc_enqueue_js('$( "select#calendar-bookings-filter" ).chosen();'); }
/** * Enqueue pointers and add script to page. * @param array $pointers */ public function enqueue_pointers($pointers) { $pointers = wp_json_encode($pointers); wp_enqueue_style('wp-pointer'); wp_enqueue_script('wp-pointer'); wc_enqueue_js("\n\t\t\tjQuery( function( \$ ) {\n\t\t\t\tvar wc_pointers = {$pointers};\n\n\t\t\t\tsetTimeout( init_wc_pointers, 800 );\n\n\t\t\t\tfunction init_wc_pointers() {\n\t\t\t\t\t\$.each( wc_pointers.pointers, function( i ) {\n\t\t\t\t\t\tshow_wc_pointer( i );\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfunction show_wc_pointer( id ) {\n\t\t\t\t\tvar pointer = wc_pointers.pointers[ id ];\n\t\t\t\t\tvar options = \$.extend( pointer.options, {\n\t\t\t\t\t\tclose: function() {\n\t\t\t\t\t\t\tif ( pointer.next ) {\n\t\t\t\t\t\t\t\tshow_wc_pointer( pointer.next );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t\tvar this_pointer = \$( pointer.target ).pointer( options );\n\t\t\t\t\tthis_pointer.pointer( 'open' );\n\n\t\t\t\t\tif ( pointer.next_trigger ) {\n\t\t\t\t\t\t\$( pointer.next_trigger.target ).on( pointer.next_trigger.event, function() {\n\t\t\t\t\t\t\tsetTimeout( function() { this_pointer.pointer( 'close' ); }, 400 );\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t"); }
/** * Adds JS code to footer on product pages * to swap width and length price calculator field rows * * This will print on any product, therefore it'd be best * to add some checks to ensure it prints on MPC products * with width and length needed fields (Area LxW measurement) */ function sv_wc_swap_mpc_rows() { // bail if we're not on a product page if (!(function_exists('is_product') && is_product())) { return; } wc_enqueue_js(' var $price_calculator = $( "#price_calculator" ); if ( $price_calculator ) { var $length_needed = $price_calculator.find( "label[for=length_needed]" ), $width_needed = $price_calculator.find( "label[for=width_needed]" ); if ( $length_needed && $width_needed ) { $length_tr = $length_needed.closest( "tr" ); $width_tr = $width_needed.closest( "tr" ); $width_tr.after( $length_tr ); } } '); }
/** * Get setting form fields for instances of this shipping method within zones. * * @return array */ public function get_instance_form_fields() { if (is_admin()) { wc_enqueue_js("\n\t\t\t\tjQuery( function( \$ ) {\n\t\t\t\t\tfunction wcFreeShippingShowHideMinAmountField( el ) {\n\t\t\t\t\t\tvar form = \$( el ).closest( 'form' );\n\t\t\t\t\t\tvar minAmountField = \$( '#woocommerce_free_shipping_min_amount', form ).closest( 'tr' );\n\t\t\t\t\t\tif ( 'coupon' === \$( el ).val() || '' === \$( el ).val() ) {\n\t\t\t\t\t\t\tminAmountField.hide();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tminAmountField.show();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t\$( document.body ).on( 'change', '#woocommerce_free_shipping_requires', function() {\n\t\t\t\t\t\twcFreeShippingShowHideMinAmountField( this );\n\t\t\t\t\t});\n\n\t\t\t\t\t// Change while load.\n\t\t\t\t\t\$( '#woocommerce_free_shipping_requires' ).change();\n\t\t\t\t\t\$( document.body ).on( 'wc_backbone_modal_loaded', function( evt, target ) {\n\t\t\t\t\t\tif ( 'wc-modal-shipping-method-settings' === target ) {\n\t\t\t\t\t\t\twcFreeShippingShowHideMinAmountField( \$( '#wc-backbone-modal-dialog #woocommerce_free_shipping_requires', evt.currentTarget ) );\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t});\n\t\t\t"); } return parent::get_instance_form_fields(); }
function init() { if (!class_exists('WooCommerce') && !class_exists('Woocommerce')) { add_action('admin_notices', array('WooCommerce_Gateways_Country_Limiter', 'woocommerce_inactive_notice')); return; } $woocommerce = function_exists('WC') ? WC() : $GLOBALS['woocommerce']; //// Before WC 2.1.x $payment_gateways = $woocommerce->payment_gateways->payment_gateways(); $current_section = empty($_GET['section']) ? '' : sanitize_title($_GET['section']); foreach ($payment_gateways as $id => $gateway) { $title = empty($gateway->method_title) ? ucfirst($gateway->id) : $gateway->method_title; $this->sections[strtolower(get_class($gateway))] = array('title' => esc_html($title), 'id' => $id); } if (is_admin() && !empty($current_section)) { add_action('woocommerce_settings_checkout', array($this, 'country_options_output'), 1000); add_action('woocommerce_update_options_checkout', array($this, 'country_options_update'), 1000); } add_filter('woocommerce_available_payment_gateways', array($this, 'filter_by_country'), 1000); //defaults foreach ($payment_gateways as $gateway_id => $gateway) { if (!isset($this->settings[$gateway_id]['option'])) { $this->settings[$gateway_id]['option'] = 'all'; } if (!isset($this->settings[$gateway_id]['countries']) || !is_array($this->settings[$gateway_id]['countries'])) { $this->settings[$gateway_id]['countries'] = array(); } } if (is_admin() && !empty($current_section)) { if (isset($this->sections[$current_section])) { $gateway_id = $this->sections[$current_section]['id']; wc_enqueue_js("\r\n \r\n jQuery(document).ready(function(){\r\n var current_option = jQuery('input[name={$gateway_id}_option]:checked');\r\n if(current_option.val() == 'all_except' || current_option.val() == 'selected'){\r\n jQuery('#pgcl_countries_list').show();\r\n current_option.parent().parent().append(jQuery('#pgcl_countries_list')); \r\n }\r\n \r\n jQuery('input[name={$gateway_id}_option]').change(function(){\r\n \r\n if(jQuery(this).val() == 'all_except' || jQuery(this).val() == 'selected'){\r\n jQuery(this).parent().parent().append(jQuery('#pgcl_countries_list')); \r\n jQuery('#pgcl_countries_list').show();\r\n }else{\r\n jQuery('#pgcl_countries_list').hide();\r\n }\r\n \r\n })\r\n })\r\n \r\n "); } } }
function tpvc_shortcode_image_carousel($atts) { extract(shortcode_atts(array('carousel_id' => '', 'images' => '', 'image_url' => '', 'image_size' => 'medium', 'single' => 'no', 'image_show' => '5', 'image_transition' => '', 'extra_class' => ''), $atts)); $output = ''; if ("" != $images) { if ('yes' == $single) { $img_per_page = 1; $singleItem = "true"; $thumb_size = 'full'; } else { if ('0' == $image_show) { $img_per_page = "5"; } else { $img_per_page = $image_show; } $singleItem = "false"; $thumb_size = $image_size; } // effect style = 'fade, backslide, godown, fadeup' if ("fade" == $image_transition) { $transitions = ',transitionStyle:"fade"'; } elseif ("backslide" == $image_transition) { $transitions = ',transitionStyle:"backSlide"'; } elseif ("godown" == $image_transition) { $transitions = ',transitionStyle:"goDown"'; } elseif ("fadeup" == $image_transition) { $transitions = ',transitionStyle:"fadeUp"'; } else { $transitions = ''; } $url_data = explode('|', $image_url); $url_array = array(); foreach ($url_data as $url_item) { $url_array[] = $url_item; } $output .= "\t" . '<div class="tpvc-image-carousel-' . $carousel_id . ' ' . $extra_class . '">' . "\n"; $output .= "\t\t" . '<div class="tpvc-image-carousel owl-carousel">' . "\n"; $images_data = explode(',', $images); $i = 0; foreach ($images_data as $image_data) { $link_url = isset($url_array[$i]) ? $url_array[$i] : "#"; $output .= "\t\t\t" . '<div class="image-carousel">' . "\n"; $output .= "\t\t\t\t" . '<a href="' . $link_url . '">' . "\n"; $output .= "\t\t\t\t\t" . wp_get_attachment_image($image_data, $thumb_size) . "\n"; $output .= "\t\t\t\t" . '</a>' . "\n"; $output .= "\t\t\t" . '</div>' . "\n"; $i++; } $output .= "\t\t" . '</div>' . "\n"; $output .= "\t" . '</div>' . "\n"; $js_code = '$(".tpvc-image-carousel-' . $carousel_id . ' .tpvc-image-carousel").owlCarousel({items:' . $img_per_page . ',itemsDesktop:[1199,4],itemsDesktopSmall:[980,3],itemsTablet:[768,2],itemsTabletSmall:false,itemsMobile:[479,1],singleItem:' . $singleItem . ',autoPlay:true,stopOnHover:true,navigation:true,navigationText:[\'<i class="fa fa-chevron-left"></i>\',\'<i class="fa fa-chevron-right"></i>\'],rewindNav:true,scrollPerPage:true,lazyLoad:true' . $transitions . '});'; if (class_exists('woocommerce')) { wc_enqueue_js($js_code); } else { tokopress_enqueue_js($js_code); } } return $output; }
/** * @since 1.0.0 of SA_WC_Compatibility_2_2 */ public static function enqueue_js($js = false) { if (self::is_wc_gte_21()) { wc_enqueue_js($js); } else { global $woocommerce; $woocommerce->add_inline_js($js); } }
function gtm4wp_woocommerce_addjs($js) { global $woocommerce; if (version_compare($woocommerce->version, "2.1", ">=")) { wc_enqueue_js($js); } else { $woocommerce->add_inline_js($js); } }
/** * Constructor */ public function __construct() { global $status, $page; $this->zone_id = (int) $_GET['zone']; $this->index = 0; //Set parent defaults parent::__construct(array('singular' => 'Shipping Method', 'plural' => 'Shipping Methods', 'ajax' => false)); wc_enqueue_js("\n\t\t\tjQuery('table.shippingmethods tbody th, table.shippingmethods tbody td').css('cursor','move');\n\n\t\t\tjQuery('table.shippingmethods tbody').sortable({\n\t\t\t\titems: 'tr:not(.inline-edit-row)',\n\t\t\t\tcursor: 'move',\n\t\t\t\taxis: 'y',\n\t\t\t\tcontainment: 'table.shippingmethods',\n\t\t\t\tscrollSensitivity: 40,\n\t\t\t\thelper: function(e, ui) {\n\t\t\t\t\tui.children().each(function() { jQuery(this).width(jQuery(this).width()); });\n\t\t\t\t\treturn ui;\n\t\t\t\t},\n\t\t\t\tstart: function(event, ui) {\n\t\t\t\t\tif ( ! ui.item.hasClass('alternate') ) ui.item.css( 'background-color', '#ffffff' );\n\t\t\t\t\tui.item.children('td,th').css('border-bottom-width','0');\n\t\t\t\t\tui.item.css( 'outline', '1px solid #dfdfdf' );\n\t\t\t\t},\n\t\t\t\tstop: function(event, ui) {\n\t\t\t\t\tui.item.removeAttr('style');\n\t\t\t\t\tui.item.children('td,th').css('border-bottom-width','1px');\n\t\t\t\t},\n\t\t\t\tupdate: function(event, ui) {\n\t\t\t\t\tjQuery('table.shippingmethods tbody th, table.shippingmethods tbody td').css('cursor','default');\n\t\t\t\t\tjQuery('table.shippingmethods tbody').sortable('disable');\n\n\t\t\t\t\tvar shipping_method_id = ui.item.find('.check-column input').val();\n\t\t\t\t\tvar prev_shipping_method_id = ui.item.prev().find('.check-column input').val();\n\t\t\t\t\tvar next_shipping_method_id = ui.item.next().find('.check-column input').val();\n\n\t\t\t\t\t// show spinner\n\t\t\t\t\tui.item.find('.check-column input').hide().after('<img alt=\"processing\" src=\"images/wpspin_light.gif\" class=\"waiting\" style=\"margin-left: 6px;\" />');\n\n\t\t\t\t\t// go do the sorting stuff via ajax\n\t\t\t\t\tjQuery.post( ajaxurl, { action: 'woocommerce_shipping_method_ordering', security: '" . wp_create_nonce('shipping-zones') . "', shipping_method_id: shipping_method_id, prev_shipping_method_id: prev_shipping_method_id, next_shipping_method_id: next_shipping_method_id }, function(response) {\n\t\t\t\t\t\tui.item.find('.check-column input').show().siblings('img').remove();\n\t\t\t\t\t\tjQuery('table.shippingmethods tbody th, table.shippingmethods tbody td').css('cursor','move');\n\t\t\t\t\t\tjQuery('table.shippingmethods tbody').sortable('enable');\n\t\t\t\t\t});\n\n\t\t\t\t\t// fix cell colors\n\t\t\t\t\tjQuery( 'table.shippingmethods tbody tr' ).each(function(){\n\t\t\t\t\t\tvar i = jQuery('table.shippingmethods tbody tr').index(this);\n\t\t\t\t\t\tif ( i%2 == 0 ) jQuery(this).addClass('alternate');\n\t\t\t\t\t\telse jQuery(this).removeClass('alternate');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\n "); }
/** * Forces a step on user-defined measurement entry, ie. only allow measurements in * increments of 0.1m * * Will be enforced on all user-defined measurements, could be scoped to specific products * if needed */ function sv_wc_measurement_price_calculator_amount_needed() { // bail if we're not on a product page if (!(function_exists('is_product') && is_product())) { return; } wc_enqueue_js(' $( "input.amount_needed" ).attr( { "step" : "0.1", "type" : "number" } ); '); }
public function product_write_panel() { global $woocommerce; $js = "\n jQuery('select#product-type').change(function(){\n if ( jQuery(this).val() == 'deposit' ) {\n jQuery('.hide_if_virtual').hide();\n jQuery('.show_if_simple').show();\n jQuery('#_virtual').attr('checked', true);\n }\n }).change();\n\n \$('input#_virtual').change(function() {\n if ( jQuery('select#product-type').val() == 'deposit' ) {\n jQuery('.show_if_simple').show();\n }\n\n });\n "; if (function_exists('wc_enqueue_js')) { wc_enqueue_js($js); } else { $woocommerce->add_inline_js($js); } }
function wc_default_variation_stock_quantity() { global $pagenow; $default_stock_quantity = 1; $screen = get_current_screen(); if (($pagenow == 'post-new.php' || $pagenow == 'post.php' || $pagenow == 'edit.php') && $screen->post_type == 'product') { $javascript = "if(jQuery( '#_stock' ).val() == null || jQuery( '#_stock' ).val() == '0') { jQuery( '#_stock' ).val(" . $default_stock_quantity . "); }"; $javascript .= "if(\$('#_sold_individually:checked').length == 0){ jQuery('#_sold_individually').val('yes').attr('checked','checked'); }"; $javascript .= "if(\$('#_manage_stock:checked').length == 0){ jQuery('#_manage_stock').val('yes').attr('checked','checked'); }"; $javascript .= "if(\$('#_regular_price').val() == null || \$('#_regular_price').val() == ''){ \$('#_regular_price').attr('required','required'); }"; wc_enqueue_js($javascript); } }
/** * Changes MPC width / length inputs to number type inputs * then adds min / max values accepted for each * * requires HTML5 support */ function sv_wc_measurement_price_calculator_input_min_max() { // bail unless we're on a product page and MPC is active if (!(is_product() && class_exists('WC_Price_Calculator_Product'))) { return; } global $product; // bail unless the calculator is enabled for this product, this is also why we hook into the footer scripts // since this isn't available immediately at page load if (!WC_Price_Calculator_Product::calculator_enabled($product)) { return; } wc_enqueue_js("\n\t\t\$('#length_needed').attr({ type: 'number', min: '.1', max: '24', step: '.1' }).addClass('input-text');\n\t\t\$('#width_needed').attr({ type: 'number', min: '.1', max: '5', step: '.1' }).addClass('input-text');\n\t"); }
function pbosfc_product_dropdown_tags() { $args = array('unit' => 'pt', 'number' => 0, 'format' => 'array', 'orderby' => 'name', 'order' => 'ASC', 'exclude' => null, 'include' => null, 'link' => 'view', 'taxonomy' => 'product_tag', 'echo' => false, 'child_of' => null); $tags = wp_tag_cloud($args); wc_enqueue_js("jQuery( '.dropdown_product_tag' ).change(\n\t\t\tfunction() {\n\t\t\t\tif ( jQuery(this).val() != '' ) {\n\t\t\t\t var this_page = '';\n\t\t\t\t var home_url = '" . esc_js(home_url('/')) . "';\n\t\t\t\t if ( home_url.indexOf( '?' ) > 0 ) {\n\t\t\t\t this_page = home_url + '&product_tag=' + jQuery(this).val();\n\t\t\t\t } else {\n\t\t\t\t this_page = home_url + '?product_tag=' + jQuery(this).val();\n\t\t\t\t }\n\t\t\t\t location.href = this_page;\n\t\t\t\t}\n\t\t\t}\n\t\t);"); $html = '<option value="">' . wp_kses_post(apply_filters('pbosfc_product_dropdown_tags_title', __('Select a tag', 'pbosfc'))) . '</option>'; foreach ($tags as $k => $v) { $slug = str_replace('tag=', '', strstr(strstr($v, 'tag='), "'", true)); $count = str_replace("title='", '', strstr(strstr($v, 'title='), " ", true)); $html = $html . '<option value="' . esc_attr($slug) . '">' . $v . ' (' . (int) $count . ')</option>'; } $html = '<select name="product_tag" class="dropdown_product_tag">' . $html . '</select>'; echo $html; }
public function inline_scripts() { $screen = get_current_screen(); if ($screen->id != 'woocommerce_page_wc-settings') { return; } $js = ' $("#woocommerce_multiple_shipping_checkout_datepicker").change(function() { if ( $(this).is(":checked") ) { $(":input.show-if-checkout-datepicker").removeAttr("disabled"); } else { $(":input.show-if-checkout-datepicker").attr("disabled", true); } }).change(); $(".datepicker-div").datepicker({ dateFormat: "mm-d-yy", showButtonPanel: true, onSelect: function(date) { var select = $(this).parents("fieldset").find("select.excluded-list"); select .append("<option selected value="+date+">"+date+"</option>") .trigger("change"); } }); $("#woocommerce_multiple_shipping_checkout_datepicker").change(function() { if ( $(this).is(":checked") ) { $(".show-if-checkout-datepicker").parents("tr").show(); } else { $(".show-if-checkout-datepicker").parents("tr").hide(); } }).change(); '; if (function_exists('wc_enqueue_js')) { wc_enqueue_js($js); } else { global $woocommerce; $woocommerce->add_inline_js($js); } ?> <style type="text/css"> .woocommerce table.ui-datepicker-calendar th { padding-right: 0 !important; } </style> <?php }
/** * Output the calendar view */ public function output() { if (version_compare(WOOCOMMERCE_VERSION, '2.3', '<')) { wp_enqueue_script('chosen'); wc_enqueue_js('$( "select#calendar-bookings-filter" ).chosen();'); } else { wp_enqueue_script('wc-enhanced-select'); } $product_filter = isset($_REQUEST['filter_bookings']) ? absint($_REQUEST['filter_bookings']) : ''; $view = isset($_REQUEST['view']) && $_REQUEST['view'] == 'day' ? 'day' : 'month'; if ($view == 'day') { $day = isset($_REQUEST['calendar_day']) ? wc_clean($_REQUEST['calendar_day']) : date('Y-m-d'); $this->bookings = WC_Bookings_Controller::get_bookings_in_date_range(strtotime('midnight', strtotime($day)), strtotime('midnight +1 day', strtotime($day)), $product_filter); } else { $month = isset($_REQUEST['calendar_month']) ? absint($_REQUEST['calendar_month']) : date('n'); $year = isset($_REQUEST['calendar_year']) ? absint($_REQUEST['calendar_year']) : date('Y'); if ($year < date('Y') - 10 || $year > 2100) { $year = date('Y'); } if ($month > 12) { $month = 1; $year++; } if ($month < 1) { $month = 1; $year--; } $start_of_week = absint(get_option('start_of_week', 1)); $last_day = date('t', strtotime("{$year}-{$month}-01")); $start_date_w = absint(date('w', strtotime("{$year}-{$month}-01"))); $end_date_w = absint(date('w', strtotime("{$year}-{$month}-{$last_day}"))); // Calc day offset $day_offset = $start_date_w - $start_of_week; $day_offset = $day_offset >= 0 ? $day_offset : 7 - abs($day_offset); // Cald end day offset $end_day_offset = 7 - $last_day % 7 - $day_offset; $end_day_offset = $end_day_offset >= 0 && $end_day_offset < 7 ? $end_day_offset : 7 - abs($end_day_offset); $start_timestamp = strtotime("-{$day_offset} day", strtotime("{$year}-{$month}-01")); $end_timestamp = strtotime("+{$end_day_offset} day", strtotime("{$year}-{$month}-{$last_day}")); $this->bookings = WC_Bookings_Controller::get_bookings_in_date_range($start_timestamp, $end_timestamp, $product_filter); } include 'views/html-calendar-' . $view . '.php'; }
function meta_box() { global $woocommerce, $post; // Providers echo '<p class="form-field tracking_provider_field"><label for="tracking_provider">' . __('Provider:', 'shipment-tracker') . '</label><br/><select id="tracking_provider" name="tracking_provider" class="chosen_select">'; $selected_provider = get_post_meta($post->ID, '_tracking_provider', true); foreach ($this->providers as $provider => $url) { echo '<option value="' . sanitize_title($provider) . '" ' . selected(sanitize_title($provider), $selected_provider, true) . '>' . $provider . '</option>'; } echo '</select> '; woocommerce_wp_text_input(array('id' => 'tracking_number', 'label' => __('Tracking number:', 'shipment-tracker'), 'placeholder' => '', 'description' => '', 'value' => get_post_meta($post->ID, '_tracking_number', true))); woocommerce_wp_text_input(array('id' => 'date_shipped', 'label' => __('Date shipped:', 'shipment-tracker'), 'placeholder' => 'YYYY-MM-DD', 'description' => '', 'class' => 'date-picker-field', 'value' => ($date = get_post_meta($post->ID, '_date_shipped', true)) ? date('Y-m-d', $date) : '')); // Live preview echo '<p class="preview_tracking_link">' . __('Preview:', 'shipment-tracker') . ' <a href="" target="_blank">' . __('Click here to track your shipment', 'shipment-tracker') . '</a></p>'; $provider_array = array(); foreach ($this->providers as $provider => $url) { $provider_array[sanitize_title($provider)] = urlencode($url); } wc_enqueue_js("\n\t\t\t\tjQuery('p.custom_tracking_link_field, p.custom_tracking_provider_field').hide();\n\n\t\t\t\tjQuery('input#custom_tracking_link, input#tracking_number, #tracking_provider').change(function(){\n\n\t\t\t\t\tvar tracking = jQuery('input#tracking_number').val();\n\t\t\t\t\tvar provider = jQuery('#tracking_provider').val();\n\t\t\t\t\tvar providers = jQuery.parseJSON( '" . json_encode($provider_array) . "' );\n\n\t\t\t\t\tvar postcode = jQuery('#_shipping_postcode').val();\n\n\t\t\t\t\tif ( ! postcode )\n\t\t\t\t\t\tpostcode = jQuery('#_billing_postcode').val();\n\n\t\t\t\t\tpostcode = encodeURIComponent( postcode );\n\n\t\t\t\t\tvar link = '';\n\n\t\t\t\t\tif ( providers[ provider ] ) {\n\t\t\t\t\t\tlink = providers[provider];\n\t\t\t\t\t\tlink = link.replace( '%7BTRACKING_URL%7D', tracking );\n\t\t\t\t\t\tlink = link.replace( '%7BPOSTCODE%7D', postcode );\n\t\t\t\t\t\tlink = decodeURIComponent( link );\n\n\t\t\t\t\t\tjQuery('p.custom_tracking_link_field, p.custom_tracking_provider_field').hide();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tjQuery('p.custom_tracking_link_field, p.custom_tracking_provider_field').show();\n\n\t\t\t\t\t\tlink = jQuery('input#custom_tracking_link').val();\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( link ) {\n\t\t\t\t\t\tjQuery('p.preview_tracking_link a').attr('href', link);\n\t\t\t\t\t\tjQuery('p.preview_tracking_link').show();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tjQuery('p.preview_tracking_link').hide();\n\t\t\t\t\t}\n\n\t\t\t\t}).change();\n\t\t\t"); }
/** * Change the admin footer text on WooCommerce admin pages. * * @since 2.3 * @param string $footer_text * @return string */ public function admin_footer_text($footer_text) { if (!current_user_can('manage_woocommerce')) { return; } $current_screen = get_current_screen(); $wc_pages = wc_get_screen_ids(); // Set only wc pages $wc_pages = array_flip($wc_pages); if (isset($wc_pages['profile'])) { unset($wc_pages['profile']); } if (isset($wc_pages['user-edit'])) { unset($wc_pages['user-edit']); } $wc_pages = array_flip($wc_pages); // Check to make sure we're on a WooCommerce admin page if (isset($current_screen->id) && apply_filters('woocommerce_display_admin_footer_text', in_array($current_screen->id, $wc_pages))) { // Change the footer text if (!get_option('woocommerce_admin_footer_text_rated')) { $footer_text = sprintf(__('If you like <strong>WooCommerce</strong> please leave us a %s★★★★★%s rating. A huge thanks in advance!', 'woocommerce'), '<a href="https://wordpress.org/support/view/plugin-reviews/woocommerce?filter=5#postform" target="_blank" class="wc-rating-link" data-rated="' . esc_attr__('Thanks :)', 'woocommerce') . '">', '</a>'); wc_enqueue_js("\n\t\t\t\t\tjQuery( 'a.wc-rating-link' ).click( function() {\n\t\t\t\t\t\tjQuery.post( '" . WC()->ajax_url() . "', { action: 'woocommerce_rated' } );\n\t\t\t\t\t\tjQuery( this ).parent().text( jQuery( this ).data( 'rated' ) );\n\t\t\t\t\t});\n\t\t\t\t"); } else { $footer_text = __('Thank you for selling with WooCommerce.', 'woocommerce'); } } return $footer_text; }
/** * Function to show gift certificates that are attached with the product */ public function show_attached_gift_certificates() { global $post, $woocommerce, $wp_rewrite; $is_show_associated_coupons = get_option('smart_coupons_is_show_associated_coupons', 'no'); if ($is_show_associated_coupons != 'yes') { return; } $coupon_titles = get_post_meta($post->ID, '_coupon_title', true); $_product = $this->get_product($post->ID); $price = $_product->get_price(); if ($coupon_titles && count($coupon_titles) > 0 && !empty($price)) { $all_discount_types = $this->is_wc_gte_21() ? wc_get_coupon_types() : $woocommerce->get_coupon_discount_types(); $smart_coupons_product_page_text = get_option('smart_coupon_product_page_text'); $smart_coupons_product_page_text = !empty($smart_coupons_product_page_text) ? $smart_coupons_product_page_text : __('By purchasing this product, you will get following coupon(s):', self::$text_domain); $list_started = true; $js = ""; foreach ($coupon_titles as $coupon_title) { $coupon = new WC_Coupon($coupon_title); $is_pick_price_of_product = get_post_meta($coupon->id, 'is_pick_price_of_product', true); if ($list_started && !empty($coupon->discount_type)) { echo '<div class="clear"></div>'; echo '<div class="gift-certificates">'; echo '<br /><p>' . __(stripslashes($smart_coupons_product_page_text)) . ''; echo '<ul>'; $list_started = false; } switch ($coupon->discount_type) { case 'smart_coupon': if ($is_pick_price_of_product == 'yes') { if ($_product->product_type == 'variable') { $js = " jQuery('div.gift-certificates').hide();\n\t\t\t\t\t\t\t\t\t\t\t\tjQuery('input[name=variation_id]').on('change', function(){\n\t \t\t\t\t\t\n\t \t\t\t\t\tvar variation_id = jQuery('input[name=variation_id]').val();\n\t \t\t\t\t\tif ( variation_id != '' && variation_id != undefined ) {\n\t \t\t\t\t\t\tjQuery('form.variations_form.cart').one( 'found_variation', function( event, variation ) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif ( variation_id = variation.variation_id ) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tjQuery('div.gift-certificates').show().fadeTo( 100, 0.4 );\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar amount = jQuery(variation.price_html).text();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tjQuery('div.gift-certificates').find('li.pick_price_from_product').remove();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tjQuery('div.gift-certificates').find('ul').append( '<li class=\"pick_price_from_product\" >' + '" . __('Store Credit of ', self::$text_domain) . "' + amount + '</li>');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tjQuery('div.gift-certificates').fadeTo( 100, 1 );\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t jQuery('a.reset_variations').on('click', function(){\n\t\t\t\t\t\t\t\t\t\t\t\t\tjQuery('div.gift-certificates').find('li.pick_price_from_product').remove();\n\t\t\t\t\t\t\t\t\t\t\t\t\tjQuery('div.gift-certificates').hide();\n\t\t\t\t\t\t\t\t\t\t\t\t});"; $amount = ""; } else { $amount = $price > 0 ? __('Store Credit of ', self::$text_domain) . $this->wc_price($price) : ""; } } else { $amount = __('Store Credit of ', self::$text_domain) . $this->wc_price($coupon->amount); } break; case 'fixed_cart': $amount = $this->wc_price($coupon->amount) . __(' discount on your entire purchase.', self::$text_domain); break; case 'fixed_product': $amount = $this->wc_price($coupon->amount) . __(' discount on product.', self::$text_domain); break; case 'percent_product': $amount = $coupon->amount . '%' . __(' discount on product.', self::$text_domain); break; case 'percent': $amount = $coupon->amount . '%' . __(' discount on your entire purchase.', self::$text_domain); break; } if (!empty($amount)) { echo '<li>' . $amount . '</li>'; } } if (!$list_started) { echo '</ul></p></div>'; } if (!empty($js)) { if ($this->is_wc_gte_21()) { wc_enqueue_js($js); } else { $woocommerce->add_inline_js($js); } } } }
/** * Enhanced search JavaScript (Select2) * * Enqueues JavaScript required for AJAX search with Select2. * * Example usage: * <input type="hidden" class="sv-wc-enhanced-search" name="category_ids" data-multiple="true" style="min-width: 300px;" * data-action="wc_cart_notices_json_search_product_categories" * data-nonce="<?php echo wp_create_nonce( 'search-categories' ); ?>" * data-request_data = "<?php echo esc_attr( json_encode( array( 'field_name' => 'something_exciting', 'default' => 'default_label' ) ) ) ?>" * data-placeholder="<?php _e( 'Search for a category…', WC_Cart_Notices::TEXT_DOMAIN ) ?>" * data-allow_clear="true" * data-selected="<?php * $json_ids = array(); * if ( isset( $notice->data['categories'] ) ) { * foreach ( $notice->data['categories'] as $value => $title ) { * $json_ids[ esc_attr( $value ) ] = esc_html( $title ); * } * } * echo esc_attr( json_encode( $json_ids ) ); * ?>" * value="<?php echo implode( ',', array_keys( $json_ids ) ); ?>" /> * * - `data-selected` can be a json encoded associative array like Array( 'key' => 'value' ) * - `value` should be a comma-seperated list of selected keys * - `data-request_data` can be used to pass any additonal data to the AJAX request * * @since 3.1.0 */ public static function render_select2_ajax() { if (!did_action('sv_wc_select2_ajax_rendered')) { $javascript = "( function(){\n\t\t\t\t\tif ( ! \$().select2 ) return;\n\t\t\t\t"; // ensure localized strings are used $javascript .= "\n\t\t\t\t\tfunction getEnhancedSelectFormatString() {\n\n\t\t\t\t\t\tif ( 'undefined' !== typeof wc_select_params ) {\n\t\t\t\t\t\t\twc_enhanced_select_params = wc_select_params;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( 'undefined' === typeof wc_enhanced_select_params ) {\n\t\t\t\t\t\t\treturn {};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvar formatString = {\n\t\t\t\t\t\t\tformatMatches: function( matches ) {\n\t\t\t\t\t\t\t\tif ( 1 === matches ) {\n\t\t\t\t\t\t\t\t\treturn wc_enhanced_select_params.i18n_matches_1;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn wc_enhanced_select_params.i18n_matches_n.replace( '%qty%', matches );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tformatNoMatches: function() {\n\t\t\t\t\t\t\t\treturn wc_enhanced_select_params.i18n_no_matches;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tformatAjaxError: function( jqXHR, textStatus, errorThrown ) {\n\t\t\t\t\t\t\t\treturn wc_enhanced_select_params.i18n_ajax_error;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tformatInputTooShort: function( input, min ) {\n\t\t\t\t\t\t\t\tvar number = min - input.length;\n\n\t\t\t\t\t\t\t\tif ( 1 === number ) {\n\t\t\t\t\t\t\t\t\treturn wc_enhanced_select_params.i18n_input_too_short_1\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn wc_enhanced_select_params.i18n_input_too_short_n.replace( '%qty%', number );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tformatInputTooLong: function( input, max ) {\n\t\t\t\t\t\t\t\tvar number = input.length - max;\n\n\t\t\t\t\t\t\t\tif ( 1 === number ) {\n\t\t\t\t\t\t\t\t\treturn wc_enhanced_select_params.i18n_input_too_long_1\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn wc_enhanced_select_params.i18n_input_too_long_n.replace( '%qty%', number );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tformatSelectionTooBig: function( limit ) {\n\t\t\t\t\t\t\t\tif ( 1 === limit ) {\n\t\t\t\t\t\t\t\t\treturn wc_enhanced_select_params.i18n_selection_too_long_1;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn wc_enhanced_select_params.i18n_selection_too_long_n.replace( '%qty%', number );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tformatLoadMore: function( pageNumber ) {\n\t\t\t\t\t\t\t\treturn wc_enhanced_select_params.i18n_load_more;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tformatSearching: function() {\n\t\t\t\t\t\t\t\treturn wc_enhanced_select_params.i18n_searching;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\treturn formatString;\n\t\t\t\t\t}\n\t\t\t\t"; // add Select2 ajax call $javascript .= "\n\t\t\t\t\t\$( ':input.sv-wc-enhanced-search' ).filter( ':not(.enhanced)' ).each( function() {\n\t\t\t\t\t\tvar select2_args = {\n\t\t\t\t\t\t\tallowClear: \$( this ).data( 'allow_clear' ) ? true : false,\n\t\t\t\t\t\t\tplaceholder: \$( this ).data( 'placeholder' ),\n\t\t\t\t\t\t\tminimumInputLength: \$( this ).data( 'minimum_input_length' ) ? \$( this ).data( 'minimum_input_length' ) : '3',\n\t\t\t\t\t\t\tescapeMarkup: function( m ) {\n\t\t\t\t\t\t\t\treturn m;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tajax: {\n\t\t\t\t\t\t\t\turl: '" . admin_url('admin-ajax.php') . "',\n\t\t\t\t\t\t\t\tdataType: 'json',\n\t\t\t\t\t\t\t\tquietMillis: 250,\n\t\t\t\t\t\t\t\tdata: function( term, page ) {\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\tterm: term,\n\t\t\t\t\t\t\t\t\t\trequest_data: \$( this ).data( 'request_data' ) ? \$( this ).data( 'request_data' ) : {},\n\t\t\t\t\t\t\t\t\t\taction: \$( this ).data( 'action' ) || 'woocommerce_json_search_products_and_variations',\n\t\t\t\t\t\t\t\t\t\tsecurity: \$( this ).data( 'nonce' )\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tresults: function( data, page ) {\n\t\t\t\t\t\t\t\t\tvar terms = [];\n\t\t\t\t\t\t\t\t\tif ( data ) {\n\t\t\t\t\t\t\t\t\t\t\$.each( data, function( id, text ) {\n\t\t\t\t\t\t\t\t\t\t\tterms.push( { id: id, text: text } );\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn { results: terms };\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tcache: true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif ( \$( this ).data( 'multiple' ) === true ) {\n\t\t\t\t\t\t\tselect2_args.multiple = true;\n\t\t\t\t\t\t\tselect2_args.initSelection = function( element, callback ) {\n\t\t\t\t\t\t\t\tvar data = \$.parseJSON( element.attr( 'data-selected' ) );\n\t\t\t\t\t\t\t\tvar selected = [];\n\n\t\t\t\t\t\t\t\t\$( element.val().split( ',' ) ).each( function( i, val ) {\n\t\t\t\t\t\t\t\t\tselected.push( { id: val, text: data[ val ] } );\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\treturn callback( selected );\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tselect2_args.formatSelection = function( data ) {\n\t\t\t\t\t\t\t\treturn '<div class=\"selected-option\" data-id=\"' + data.id + '\">' + data.text + '</div>';\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tselect2_args.multiple = false;\n\t\t\t\t\t\t\tselect2_args.initSelection = function( element, callback ) {\n\t\t\t\t\t\t\t\tvar data = {id: element.val(), text: element.attr( 'data-selected' )};\n\t\t\t\t\t\t\t\treturn callback( data );\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tselect2_args = \$.extend( select2_args, getEnhancedSelectFormatString() );\n\n\t\t\t\t\t\t\$( this ).select2( select2_args ).addClass( 'enhanced' );\n\t\t\t\t\t});\n\t\t\t\t"; $javascript .= "} )();"; wc_enqueue_js($javascript); do_action('sv_wc_select2_ajax_rendered'); } }
function dashboard_currency_dropdown() { global $woocommerce_wpml, $sitepress; $current_dashboard_currency = $this->get_cookie_dashboard_currency(); $wc_currencies = get_woocommerce_currencies(); $order_currencies = $this->get_orders_currencies(); ?> <select id="dropdown_dashboard_currency" style="display: none; margin : 10px; "> <?php foreach ($order_currencies as $currency => $count) { ?> <option value="<?php echo $currency; ?> " <?php echo $current_dashboard_currency == $currency ? 'selected="selected"' : ''; ?> ><?php echo $wc_currencies[$currency]; ?> </option> <?php } ?> </select> <?php wc_enqueue_js("\n\n jQuery(document).ready(function(){\n\n var dashboard_dropdown = jQuery('#dropdown_dashboard_currency').clone();\n jQuery('#dropdown_dashboard_currency').remove();\n dashboard_dropdown.insertBefore('.sales-this-month a').show();\n jQuery('#woocommerce_dashboard_status .wc_status_list li').css('display','table');\n\n });\n\n jQuery(document).on('change', '#dropdown_dashboard_currency', function(){\n jQuery.ajax({\n url: ajaxurl,\n type: 'post',\n data: {action: 'wcml_dashboard_set_currency', currency: jQuery('#dropdown_dashboard_currency').val()},\n success: function(){location.reload();}\n })\n });\n "); }
/** * Includes inline JavaScript. * * @param $js */ protected function run_js($js) { global $woocommerce; if (function_exists('wc_enqueue_js')) { wc_enqueue_js($js); } else { $woocommerce->add_inline_js($js); } }
/** * Enqueue scripts. * * Enqueue style and java scripts. * * @since 1.0.0 */ public function admin_enqueue_scripts() { // Only load scripts on relvant pages if (isset($_REQUEST['post']) && 'shipping_zone' == get_post_type($_REQUEST['post']) || isset($_REQUEST['post_type']) && 'shipping_zone' == $_REQUEST['post_type'] || isset($_REQUEST['tab']) && 'shipping_zones' == $_REQUEST['tab']) { // Style script wp_enqueue_style('woocommerce-advanced-shipping-zones', plugins_url('assets/css/woocommerce-advanced-shipping-zones.css', __FILE__), array()); wp_enqueue_style('woocommerce-advanced-shipping-css', plugins_url('assets/admin/css/woocommerce-advanced-shipping.css', WAS()->file), array(), WAS()->version); // Chosen script wp_enqueue_script('chosen', WC()->plugin_url() . '/assets/js/chosen/chosen.jquery.min.js', array('jquery'), WC_VERSION); // Chosen style wp_enqueue_style('woocommerce_chosen_styles', str_replace(array('http:', 'https:'), '', WC()->plugin_url()) . '/assets/css/chosen.css'); // Set chosen wc_enqueue_js('$(".chosen").chosen({search_contains: true});'); } }
/** * Admin Options * * Setup the email settings screen. * Override this in your email. * * @since 1.0.0 */ public function admin_options() { // Do admin actions. $this->admin_actions(); ?> <h3><?php echo !empty($this->title) ? $this->title : __('Settings', 'woocommerce'); ?> </h3> <?php echo !empty($this->description) ? wpautop($this->description) : ''; ?> <?php /** * woocommerce_email_settings_before action hook * * @param string $email The email object */ do_action('woocommerce_email_settings_before', $this); ?> <table class="form-table"> <?php $this->generate_settings_html(); ?> </table> <?php /** * woocommerce_email_settings_after action hook * * @param string $email The email object */ do_action('woocommerce_email_settings_after', $this); ?> <?php if (current_user_can('edit_themes') && (!empty($this->template_html) || !empty($this->template_plain))) { ?> <div id="template"> <?php $templates = array('template_html' => __('HTML template', 'woocommerce'), 'template_plain' => __('Plain text template', 'woocommerce')); foreach ($templates as $template_type => $title) { $template = $this->get_template($template_type); if (empty($template)) { continue; } $local_file = $this->get_theme_template_file($template); $core_file = $this->template_base . $template; $template_file = apply_filters('woocommerce_locate_core_template', $core_file, $template, $this->template_base); $template_dir = apply_filters('woocommerce_template_directory', 'woocommerce', $template); ?> <div class="template <?php echo $template_type; ?> "> <h4><?php echo wp_kses_post($title); ?> </h4> <?php if (file_exists($local_file)) { ?> <p> <a href="#" class="button toggle_editor"></a> <?php if (is_writable($local_file)) { ?> <a href="<?php echo esc_url(wp_nonce_url(remove_query_arg(array('move_template', 'saved'), add_query_arg('delete_template', $template_type)), 'woocommerce_email_template_nonce', '_wc_email_nonce')); ?> " class="delete_template button"><?php _e('Delete template file', 'woocommerce'); ?> </a> <?php } ?> <?php printf(__('This template has been overridden by your theme and can be found in: <code>%s</code>.', 'woocommerce'), 'yourtheme/' . $template_dir . '/' . $template); ?> </p> <div class="editor" style="display:none"> <textarea class="code" cols="25" rows="20" <?php if (!is_writable($local_file)) { ?> readonly="readonly" disabled="disabled"<?php } else { ?> data-name="<?php echo $template_type . '_code'; ?> "<?php } ?> ><?php echo file_get_contents($local_file); ?> </textarea> </div> <?php } elseif (file_exists($template_file)) { ?> <p> <a href="#" class="button toggle_editor"></a> <?php if (is_dir(get_stylesheet_directory() . '/' . $template_dir . '/emails/') && is_writable(get_stylesheet_directory() . '/' . $template_dir . '/emails/') || is_writable(get_stylesheet_directory())) { ?> <a href="<?php echo esc_url(wp_nonce_url(remove_query_arg(array('delete_template', 'saved'), add_query_arg('move_template', $template_type)), 'woocommerce_email_template_nonce', '_wc_email_nonce')); ?> " class="button"><?php _e('Copy file to theme', 'woocommerce'); ?> </a> <?php } ?> <?php printf(__('To override and edit this email template copy <code>%s</code> to your theme folder: <code>%s</code>.', 'woocommerce'), plugin_basename($template_file), 'yourtheme/' . $template_dir . '/' . $template); ?> </p> <div class="editor" style="display:none"> <textarea class="code" readonly="readonly" disabled="disabled" cols="25" rows="20"><?php echo file_get_contents($template_file); ?> </textarea> </div> <?php } else { ?> <p><?php _e('File was not found.', 'woocommerce'); ?> </p> <?php } ?> </div> <?php } ?> </div> <?php wc_enqueue_js("\r\n\t\t\t\tjQuery( 'select.email_type' ).change( function() {\r\n\r\n\t\t\t\t\tvar val = jQuery( this ).val();\r\n\r\n\t\t\t\t\tjQuery( '.template_plain, .template_html' ).show();\r\n\r\n\t\t\t\t\tif ( val != 'multipart' && val != 'html' ) {\r\n\t\t\t\t\t\tjQuery('.template_html').hide();\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif ( val != 'multipart' && val != 'plain' ) {\r\n\t\t\t\t\t\tjQuery('.template_plain').hide();\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}).change();\r\n\r\n\t\t\t\tvar view = '" . esc_js(__('View template', 'woocommerce')) . "';\r\n\t\t\t\tvar hide = '" . esc_js(__('Hide template', 'woocommerce')) . "';\r\n\r\n\t\t\t\tjQuery( 'a.toggle_editor' ).text( view ).toggle( function() {\r\n\t\t\t\t\tjQuery( this ).text( hide ).closest(' .template' ).find( '.editor' ).slideToggle();\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}, function() {\r\n\t\t\t\t\tjQuery( this ).text( view ).closest( '.template' ).find( '.editor' ).slideToggle();\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t} );\r\n\r\n\t\t\t\tjQuery( 'a.delete_template' ).click( function() {\r\n\t\t\t\t\tif ( window.confirm('" . esc_js(__('Are you sure you want to delete this template file?', 'woocommerce')) . "') ) {\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t});\r\n\r\n\t\t\t\tjQuery( '.editor textarea' ).change( function() {\r\n\t\t\t\t\tvar name = jQuery( this ).attr( 'data-name' );\r\n\r\n\t\t\t\t\tif ( name ) {\r\n\t\t\t\t\t\tjQuery( this ).attr( 'name', name );\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t"); } }
/** * Output for the order received page. * * @param $order_id Order ID. * * @return string PagSeguro lightbox. */ public function receipt_page($order_id) { global $woocommerce; $order = new WC_Order($order_id); $request_data = $_POST; if (isset($_GET['use_shipping']) && true == $_GET['use_shipping']) { $request_data['ship_to_different_address'] = true; } $response = $this->api->do_checkout_request($order, $request_data); if ($response['url']) { // Lightbox script. $js = ' $( "#browser-has-javascript" ).show(); $( "#browser-no-has-javascript, #cancel-payment, #submit-payment" ).hide(); var isOpenLightbox = PagSeguroLightbox({ code: "' . esc_attr($response['token']) . '" }, { success: function ( transactionCode ) { window.location.href = "' . str_replace('&', '&', $this->get_return_url($order)) . '"; }, abort: function () { window.location.href = "' . str_replace('&', '&', $order->get_cancel_order_url()) . '"; } }); if ( ! isOpenLightbox ) { window.location.href = "' . $response['url'] . '"; } '; if (function_exists('wc_enqueue_js')) { wc_enqueue_js($js); } else { $woocommerce->add_inline_js($js); } woocommerce_get_template('lightbox-checkout.php', array('cancel_order_url' => $order->get_cancel_order_url(), 'payment_url' => $response['url'], 'lightbox_script_url' => $this->api->get_lightbox_url()), 'woocommerce/pagseguro/', WC_PagSeguro::get_templates_path()); } else { $html = '<ul class="woocommerce-error">'; foreach ($response['error'] as $message) { $html .= '<li>' . $message . '</li>'; } $html .= '</ul>'; $html .= '<a class="button cancel" href="' . esc_url($order->get_cancel_order_url()) . '">' . __('Click to try again', 'woocommerce-pagseguro') . '</a>'; echo $html; } }
/** * Add select customer scripts * * @Author Andrea Grillo <*****@*****.**> * @since 1.0.0 * @return void * @use woocommerce_json_search_customers action */ public function add_select_customer_script() { $inline_js = "\r\n jQuery('select.ajax_chosen_select_customer').ajaxChosen({\r\n method: \t\t'GET',\r\n url: \t\t\t'" . admin_url('admin-ajax.php') . "',\r\n dataType: \t\t'json',\r\n afterTypeDelay: 100,\r\n minTermLength: \t1,\r\n data:\t\t{\r\n action: \t'woocommerce_json_search_customers',\r\n security: \t'" . wp_create_nonce("search-customers") . "',\r\n default: \t'',\r\n plugin: '" . YITH_WPV_SLUG . "'\r\n }\r\n }, function (data) {\r\n\r\n var terms = {};\r\n\r\n \$.each(data, function (i, val) {\r\n terms[i] = val;\r\n });\r\n\r\n return terms;\r\n });\r\n "; wc_enqueue_js($inline_js); }
public function meta_box_inner($post) { wp_nonce_field('wc_bookings_details_meta_box', 'wc_bookings_details_meta_box_nonce'); // Scripts. wp_enqueue_script('ajax-chosen'); wp_enqueue_script('chosen'); wp_enqueue_script('jquery-ui-datepicker'); $customer_id = get_post_meta($post->ID, '_booking_customer_id', true); $order_parent_id = apply_filters('woocommerce_order_number', _x('#', 'hash before order number', 'woocommerce-bookings') . $post->post_parent, $post->post_parent); ?> <style type="text/css"> #post-body-content, #titlediv, #major-publishing-actions, #minor-publishing-actions, #visibility, #submitdiv { display:none } </style> <div class="panel-wrap woocommerce"> <div id="booking_data" class="panel"> <h2><?php _e('Booking Details', 'woocommerce-bookings'); ?> </h2> <p class="booking_number"><?php printf(__('Booking number: #%s.', 'woocommerce-bookings'), esc_html($post->ID)); if ($post->post_parent) { $order = new WC_Order($post->post_parent); printf(' ' . __('Order number: %s.', 'woocommerce-bookings'), '<a href="' . admin_url('post.php?post=' . absint($post->post_parent) . '&action=edit') . '">' . esc_html($order->get_order_number()) . '</a>'); } ?> </p> <div class="booking_data_column_container"> <div class="booking_data_column"> <h4><?php _e('General Details', 'woocommerce-bookings'); ?> </h4> <p class="form-field form-field-wide"> <label for="_booking_order_id"><?php _e('Order ID:', 'woocommerce-bookings'); ?> </label> <select id="_booking_order_id" name="_booking_order_id" class="ajax_chosen_select_booking_order_id" data-placeholder="<?php _e('Select an order…', 'woocommerce-bookings'); ?> "> <?php if ($post->post_parent) { echo '<option value="' . esc_attr($post->post_parent) . '" ' . selected(1, 1, false) . '>' . $order_parent_id . ' – ' . esc_html(get_the_title($post->post_parent)) . '</option>'; } ?> </select> </p> <p class="form-field form-field-wide"><label for="booking_date"><?php _e('Date created:', 'woocommerce-bookings'); ?> </label> <input type="text" class="date-picker-field" name="booking_date" id="booking_date" maxlength="10" value="<?php echo date_i18n('Y-m-d', strtotime($post->post_date)); ?> " pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" /> @ <input type="text" class="hour" placeholder="<?php _e('h', 'woocommerce-bookings'); ?> " name="booking_date_hour" id="booking_date_hour" maxlength="2" size="2" value="<?php echo date_i18n('H', strtotime($post->post_date)); ?> " pattern="\-?\d+(\.\d{0,})?" />:<input type="text" class="minute" placeholder="<?php _e('m', 'woocommerce-bookings'); ?> " name="booking_date_minute" id="booking_date_minute" maxlength="2" size="2" value="<?php echo date_i18n('i', strtotime($post->post_date)); ?> " pattern="\-?\d+(\.\d{0,})?" /> </p> <?php $statuses = array('unpaid' => __('unpaid', 'woocommerce-bookings'), 'pending' => __('pending', 'woocommerce-bookings'), 'confirmed' => __('confirmed', 'woocommerce-bookings'), 'paid' => __('paid', 'woocommerce-bookings'), 'cancelled' => __('cancelled', 'woocommerce-bookings'), 'complete' => __('complete', 'woocommerce-bookings')); ?> <p class="form-field form-field-wide"> <label for="_booking_status"><?php _e('Booking Status:', 'woocommerce-bookings'); ?> </label> <select id="_booking_status" name="_booking_status"> <?php foreach ($statuses as $key => $value) { echo '<option value="' . esc_attr($key) . '" ' . selected($key, $post->post_status, false) . '>' . esc_html__($value, 'woocommerce-bookings') . '</option>'; } ?> </select> </p> <p class="form-field form-field-wide"> <label for="_booking_customer_id"><?php _e('Customer:', 'woocommerce-bookings'); ?> </label> <select id="_booking_customer_id" name="_booking_customer_id" class="ajax_chosen_select_customer"> <option value=""><?php _e('Guest', 'woocommerce-bookings'); ?> </option> <?php if ($customer_id) { $user = get_user_by('id', $customer_id); echo '<option value="' . esc_attr($user->ID) . '" ' . selected(1, 1, false) . '>' . esc_html($user->display_name) . ' (#' . absint($user->ID) . ' – ' . esc_html($user->user_email) . ')</option>'; } ?> </select> </p> <?php do_action('woocommerce_admin_booking_data_after_booking_details', $post->ID); ?> </div> <div class="booking_data_column"> <h4><?php _e('Booking Specification', 'woocommerce-bookings'); ?> </h4> <?php $bookable_products = array('' => __('N/A', 'woocommerce-bookings')); $products = WC_Bookings_Admin::get_booking_products(); foreach ($products as $product) { $bookable_products[$product->ID] = $product->post_title; $resources = wc_booking_get_product_resources($product->ID); foreach ($resources as $resource) { $bookable_products[$product->ID . '=>' . $resource->ID] = ' ' . $resource->post_title; } } $product_id = get_post_meta($post->ID, '_booking_product_id', true); $resource_id = get_post_meta($post->ID, '_booking_resource_id', true); woocommerce_wp_select(array('id' => 'product_or_resource_id', 'label' => __('Booked Product', 'woocommerce-bookings'), 'options' => $bookable_products, 'value' => $resource_id ? $product_id . '=>' . $resource_id : $product_id)); woocommerce_wp_text_input(array('id' => '_booking_parent_id', 'label' => __('Parent Booking ID', 'woocommerce-bookings'), 'placeholder' => 'N/A')); $persons = get_post_meta($post->ID, '_booking_persons', true); if (!empty($persons) && is_array($persons)) { echo '<br class="clear" />'; echo '<h4>' . __('Person(s)', 'woocommerce-bookings') . '</h4>'; foreach ($persons as $person_id => $person_count) { woocommerce_wp_text_input(array('id' => '_booking_person_' . $person_id, 'label' => get_the_title($person_id), 'placeholder' => '0', 'value' => $person_count, 'wrapper_class' => 'booking-person')); } } ?> </div> <div class="booking_data_column"> <h4><?php _e('Booking Date/Time', 'woocommerce-bookings'); ?> </h4> <?php woocommerce_wp_text_input(array('id' => 'booking_start_date', 'label' => __('Start date', 'woocommerce-bookings'), 'placeholder' => 'yyyy-mm-dd', 'value' => date('Y-m-d', strtotime(get_post_meta($post->ID, '_booking_start', true))), 'class' => 'date-picker-field')); woocommerce_wp_text_input(array('id' => 'booking_end_date', 'label' => __('End date', 'woocommerce-bookings'), 'placeholder' => 'yyyy-mm-dd', 'value' => date('Y-m-d', strtotime(get_post_meta($post->ID, '_booking_end', true))), 'class' => 'date-picker-field')); woocommerce_wp_checkbox(array('id' => '_booking_all_day', 'label' => __('All day', 'woocommerce-bookings'), 'description' => __('Check this box if the booking is for all day.', 'woocommerce-bookings'), 'value' => get_post_meta($post->ID, '_booking_all_day', true) ? 'yes' : 'no')); woocommerce_wp_text_input(array('id' => 'booking_start_time', 'label' => __('Start time', 'woocommerce-bookings'), 'placeholder' => 'hh:mm', 'value' => date('H:i', strtotime(get_post_meta($post->ID, '_booking_start', true))), 'class' => 'datepicker')); woocommerce_wp_text_input(array('id' => 'booking_end_time', 'label' => __('End time', 'woocommerce-bookings'), 'placeholder' => 'hh:mm', 'value' => date('H:i', strtotime(get_post_meta($post->ID, '_booking_end', true))))); ?> </div> </div> <div class="clear"></div> </div> <?php wc_enqueue_js("\n\t\t\t\t\$( '#_booking_all_day' ).change( function () {\n\t\t\t\t\tif ( \$( this ).is( ':checked' ) ) {\n\t\t\t\t\t\t\$( '#booking_start_time, #booking_end_time' ).closest( 'p' ).hide();\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\$( '#booking_start_time, #booking_end_time' ).closest( 'p' ).show();\n\t\t\t\t\t}\n\t\t\t\t}).change();\n\n\t\t\t\t\$( 'select#_booking_order_id' ).ajaxChosen({\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\turl: '" . admin_url('admin-ajax.php') . "',\n\t\t\t\t\tdataType: 'json',\n\t\t\t\t\tafterTypeDelay: 100,\n\t\t\t\t\tminTermLength: 1,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\taction: 'wc_bookings_json_search_order',\n\t\t\t\t\t\tsecurity: '" . wp_create_nonce('search-booking-order') . "'\n\t\t\t\t\t}\n\t\t\t\t}, function ( data ) {\n\n\t\t\t\t\tvar orders = {};\n\n\t\t\t\t\t\$.each( data, function ( i, val ) {\n\t\t\t\t\t\torders[i] = val;\n\t\t\t\t\t});\n\n\t\t\t\t\treturn orders;\n\t\t\t\t});\n\n\t\t\t\t\$( 'select#_booking_status' ).chosen({\n\t\t\t\t\tdisable_search: true\n\t\t\t\t});\n\n\t\t\t\t\$( 'select.ajax_chosen_select_customer' ).ajaxChosen({\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\turl: '" . admin_url('admin-ajax.php') . "',\n\t\t\t\t\tdataType: 'json',\n\t\t\t\t\tafterTypeDelay: 100,\n\t\t\t\t\tminTermLength: 1,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\taction: 'woocommerce_json_search_customers',\n\t\t\t\t\t\tsecurity: '" . wp_create_nonce('search-customers') . "'\n\t\t\t\t\t}\n\t\t\t\t}, function ( data ) {\n\n\t\t\t\t\tvar terms = {};\n\n\t\t\t\t\t\$.each( data, function ( i, val ) {\n\t\t\t\t\t\tterms[i] = val;\n\t\t\t\t\t});\n\n\t\t\t\t\treturn terms;\n\t\t\t\t});\n\n\t\t\t\t\$( 'select#product_or_resource_id' ).chosen();\n\n\t\t\t\t\$( '.date-picker-field' ).datepicker({\n\t\t\t\t\tdateFormat: 'yy-mm-dd',\n\t\t\t\t\tnumberOfMonths: 1,\n\t\t\t\t\tshowButtonPanel: true,\n\t\t\t\t});\n\t\t\t"); }
/** * Output the countdown timer. This defaults to the following format, where * elments in [ ] are not shown if zero: * * [y Years] [o Months] [d Days] h Hours m Minutes s Seconds * * The following shortcode arguments are optional: * * * product_id/product_sku - id or sku of pre-order product to countdown to. * Defaults to current product, if any * * until - date/time to count down to, overrides product release date * if set. Example values: "15 March 2015", "+1 month". * More examples: http://php.net/manual/en/function.strtotime.php * * before - text to show before the countdown. Only available if 'layout' is not '' * * after - text to show after the countdown. Only available if 'layout' is not '' * * layout - The countdown layout, defaults to y Years o Months d Days h Hours m Minutes s Seconds * See http://keith-wood.name/countdownRef.html#layout for all possible options * * format - The format for the countdown display. Example: 'yodhms' * to display the year, month, day and time. See http://keith-wood.name/countdownRef.html#format for all options * * compact - If 'true' displays the date/time labels in compact form, ie * 'd' rather than 'days'. Defaults to 'false' * * When the countdown date/time is reached the page will refresh. * * To test different time periods you can create shortcodes like the following samples: * * [woocommerce_pre_order_countdown until="+10 year"] * [woocommerce_pre_order_countdown until="+10 month"] * [woocommerce_pre_order_countdown until="+10 day"] * [woocommerce_pre_order_countdown until="+10 second"] * * @param array $atts associative array of shortcode parameters */ public static function output($atts) { global $woocommerce, $product, $wpdb; extract(shortcode_atts(array('product_id' => '', 'product_sku' => '', 'until' => '', 'before' => '', 'after' => '', 'layout' => '{y<}{yn} {yl}{y>} {o<}{on} {ol}{o>} {d<}{dn} {dl}{d>} {hn} {hl} {mn} {ml} {sn} {sl}', 'format' => 'yodHMS', 'compact' => 'false'), $atts)); // product by sku? if ($product_sku) { $product_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_sku' AND meta_value=%s LIMIT 1", $product_sku)); } // product by id? if ($product_id) { $product = get_product($product_id); } // date override (convert from string unless someone was savvy enough to provide a timestamp) if ($until && !is_numeric($until)) { $until = strtotime($until); } // product and no date override, get the datetime from the product, if there is one if ($product && !$until) { $until = $product->wc_pre_orders_availability_datetime ? $product->wc_pre_orders_availability_datetime : 0; } // can't do anything without an 'until' date if (!$until) { return; } // if a layout is being used, prepend/append the before/after text if ($layout) { $layout = esc_js($before) . $layout . esc_js($after); } // enqueue the required javascripts self::enqueue_scripts(); // countdown javascript ob_start(); ?> $('#woocommerce-pre-orders-countdown-<?php echo $until; ?> ').countdown({ until: new Date(<?php echo $until * 1000; ?> ), layout: '<?php echo $layout; ?> ', 'format': '<?php echo $format; ?> ', compact: <?php echo $compact; ?> , expiryUrl: location.href, }); <?php $javascript = ob_get_clean(); if (function_exists('wc_enqueue_js')) { wc_enqueue_js($javascript); } else { $woocommerce->add_inline_js($javascript); } // the countdown element with a unique identifier to allow multiple countdowns on the same page, and common class for ease of styling echo '<div class="woocommerce-pre-orders-countdown" id="woocommerce-pre-orders-countdown-' . $until . '"></div>'; }
/** * widget function. * * @see WP_Widget * * @param array $args * @param array $instance */ public function widget($args, $instance) { global $wp_query, $post; $c = isset($instance['count']) ? $instance['count'] : $this->settings['count']['std']; $h = isset($instance['hierarchical']) ? $instance['hierarchical'] : $this->settings['hierarchical']['std']; $s = isset($instance['show_children_only']) ? $instance['show_children_only'] : $this->settings['show_children_only']['std']; $d = isset($instance['dropdown']) ? $instance['dropdown'] : $this->settings['dropdown']['std']; $o = isset($instance['orderby']) ? $instance['orderby'] : $this->settings['orderby']['std']; $dropdown_args = array('hide_empty' => false); $list_args = array('show_count' => $c, 'hierarchical' => $h, 'taxonomy' => 'product_cat', 'hide_empty' => false); // Menu Order $list_args['menu_order'] = false; if ($o == 'order') { $list_args['menu_order'] = 'asc'; } else { $list_args['orderby'] = 'title'; } // Setup Current Category $this->current_cat = false; $this->cat_ancestors = array(); if (is_tax('product_cat')) { $this->current_cat = $wp_query->queried_object; $this->cat_ancestors = get_ancestors($this->current_cat->term_id, 'product_cat'); } elseif (is_singular('product')) { $product_category = wc_get_product_terms($post->ID, 'product_cat', array('orderby' => 'parent')); if ($product_category) { $this->current_cat = end($product_category); $this->cat_ancestors = get_ancestors($this->current_cat->term_id, 'product_cat'); } } // Show Siblings and Children Only if ($s && $this->current_cat) { // Top level is needed $top_level = get_terms('product_cat', array('fields' => 'ids', 'parent' => 0, 'hierarchical' => true, 'hide_empty' => false)); // Direct children are wanted $direct_children = get_terms('product_cat', array('fields' => 'ids', 'parent' => $this->current_cat->term_id, 'hierarchical' => true, 'hide_empty' => false)); // Gather siblings of ancestors $siblings = array(); if ($this->cat_ancestors) { foreach ($this->cat_ancestors as $ancestor) { $ancestor_siblings = get_terms('product_cat', array('fields' => 'ids', 'parent' => $ancestor, 'hierarchical' => false, 'hide_empty' => false)); $siblings = array_merge($siblings, $ancestor_siblings); } } if ($h) { $include = array_merge($top_level, $this->cat_ancestors, $siblings, $direct_children, array($this->current_cat->term_id)); } else { $include = array_merge($direct_children); } $dropdown_args['include'] = implode(',', $include); $list_args['include'] = implode(',', $include); if (empty($include)) { return; } } elseif ($s) { $dropdown_args['depth'] = 1; $dropdown_args['child_of'] = 0; $dropdown_args['hierarchical'] = 1; $list_args['depth'] = 1; $list_args['child_of'] = 0; $list_args['hierarchical'] = 1; } $this->widget_start($args, $instance); // Dropdown if ($d) { $dropdown_defaults = array('show_counts' => $c, 'hierarchical' => $h, 'show_uncategorized' => 0, 'orderby' => $o, 'selected' => $this->current_cat ? $this->current_cat->slug : ''); $dropdown_args = wp_parse_args($dropdown_args, $dropdown_defaults); // Stuck with this until a fix for http://core.trac.wordpress.org/ticket/13258 wc_product_dropdown_categories(apply_filters('woocommerce_product_categories_widget_dropdown_args', $dropdown_args)); wc_enqueue_js("\n\t\t\t\tjQuery( '.dropdown_product_cat' ).change( function() {\n\t\t\t\t\tif ( jQuery(this).val() != '' ) {\n\t\t\t\t\t\tvar this_page = '';\n\t\t\t\t\t\tvar home_url = '" . esc_js(home_url('/')) . "';\n\t\t\t\t\t\tif ( home_url.indexOf( '?' ) > 0 ) {\n\t\t\t\t\t\t\tthis_page = home_url + '&product_cat=' + jQuery(this).val();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis_page = home_url + '?product_cat=' + jQuery(this).val();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlocation.href = this_page;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t"); // List } else { include_once WC()->plugin_path() . '/includes/walkers/class-product-cat-list-walker.php'; $list_args['walker'] = new WC_Product_Cat_List_Walker(); $list_args['title_li'] = ''; $list_args['pad_counts'] = 1; $list_args['show_option_none'] = __('No product categories exist.', 'woocommerce'); $list_args['current_category'] = $this->current_cat ? $this->current_cat->term_id : ''; $list_args['current_category_ancestors'] = $this->cat_ancestors; echo '<ul class="product-categories">'; wp_list_categories(apply_filters('woocommerce_product_categories_widget_args', $list_args)); echo '</ul>'; } $this->widget_end($args); }
/** * Generate the twocheckout button link * * @access public * @param mixed $order_id * @return string */ function generate_twocheckout_form($order_id) { global $woocommerce; $order = new WC_Order($order_id); $twocheckout_args = $this->get_twocheckout_args($order); $twocheckout_args_array = array(); foreach ($twocheckout_args as $key => $value) { $twocheckout_args_array[] = '<input type="hidden" name="' . esc_attr($key) . '" value="' . esc_attr($value) . '" />'; } wc_enqueue_js(' jQuery("body").block({ message: "' . esc_js(__('Thank you for your order. We are now redirecting you to PayPal to make payment.', 'woocommerce')) . '", baseZ: 99999, overlayCSS: { background: "#fff", opacity: 0.6 }, css: { padding: "20px", zindex: "9999999", textAlign: "center", color: "#555", border: "3px solid #aaa", backgroundColor:"#fff", cursor: "wait", lineHeight: "24px", } }); jQuery("#submit_twocheckout_payment_form").click(); '); return '<form action="https://www.2checkout.com/checkout/purchase" method="post" id="paypal_payment_form" target="_top"> ' . implode('', $twocheckout_args_array) . ' <input type="submit" class="button alt" id="submit_twocheckout_payment_form" value="' . __('Pay via PayPal', 'woocommerce') . '" /> <a class="button cancel" href="' . esc_url($order->get_cancel_order_url()) . '">' . __('Cancel order & restore cart', 'woocommerce') . '</a> </form>'; }