本文整理汇总了PHP中wc_enqueue_js函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_enqueue_js函数的具体用法?PHP wc_enqueue_js怎么用?PHP wc_enqueue_js使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_enqueue_js函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: output
/**
* 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();');
}
开发者ID:nomadicmarc,项目名称:goodbay,代码行数:35,代码来源:class-wc-bookings-calendar.php
示例2: enqueue_pointers
/**
* 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");
}
开发者ID:tlovett1,项目名称:woocommerce,代码行数:11,代码来源:class-wc-admin-pointers.php
示例3: sv_wc_swap_mpc_rows
/**
* 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 );
}
}
');
}
开发者ID:skyverge,项目名称:wc-plugins-snippets,代码行数:34,代码来源:invert-needed-width-length-for-area-inputs.php
示例4: get_instance_form_fields
/**
* 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();
}
开发者ID:woocommerce,项目名称:woocommerce,代码行数:12,代码来源:class-wc-shipping-free-shipping.php
示例5: init
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 ");
}
}
}
开发者ID:Alexg10,项目名称:Egzobeatbox,代码行数:35,代码来源:woocommerce-gateways-country-limiter.php
示例6: tpvc_shortcode_image_carousel
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;
}
开发者ID:Artgorae,项目名称:wp-artgorae,代码行数:59,代码来源:image_carousel.php
示例7: enqueue_js
/**
* @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);
}
}
开发者ID:WP-Panda,项目名称:allergenics,代码行数:12,代码来源:class-wc-compatibility-2-2.php
示例8: gtm4wp_woocommerce_addjs
function gtm4wp_woocommerce_addjs($js)
{
global $woocommerce;
if (version_compare($woocommerce->version, "2.1", ">=")) {
wc_enqueue_js($js);
} else {
$woocommerce->add_inline_js($js);
}
}
开发者ID:venamax,项目名称:trixandtrax-cl,代码行数:9,代码来源:woocommerce.php
示例9: __construct
/**
* 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 ");
}
开发者ID:arobbins,项目名称:spellestate,代码行数:12,代码来源:class-wc-shipping-zone-methods-table.php
示例10: sv_wc_measurement_price_calculator_amount_needed
/**
* 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" } );
');
}
开发者ID:skyverge,项目名称:wc-plugins-snippets,代码行数:17,代码来源:add-steps-to-user-inputs.php
示例11: product_write_panel
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);
}
}
开发者ID:bulbulbigboss,项目名称:bigboss-woocommerce-deposit-funds,代码行数:10,代码来源:class-wcaf-product-admin.php
示例12: wc_default_variation_stock_quantity
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);
}
}
开发者ID:elawn,项目名称:wicked,代码行数:13,代码来源:woo_custom.php
示例13: sv_wc_measurement_price_calculator_input_min_max
/**
* 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");
}
开发者ID:skyverge,项目名称:wc-plugins-snippets,代码行数:20,代码来源:add-min-max-input-values.php
示例14: pbosfc_product_dropdown_tags
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;
}
开发者ID:boguslawski-piotr,项目名称:pbo-storefront-compact,代码行数:14,代码来源:shortcodes.php
示例15: inline_scripts
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
}
开发者ID:RainyDayMedia,项目名称:carbide-probes,代码行数:50,代码来源:multi-shipping.php
示例16: output
/**
* 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';
}
开发者ID:tonyvu1985,项目名称:appletutorings,代码行数:46,代码来源:class-wc-bookings-calendar.php
示例17: meta_box
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");
}
开发者ID:ksere,项目名称:shipment_tracker_for_woocommerce,代码行数:20,代码来源:shipment-tracker.php
示例18: admin_footer_text
/**
* 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;
}
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:35,代码来源:class-wc-admin.php
示例19: show_attached_gift_certificates
/**
* 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);
}
}
}
}
开发者ID:NerdyDillinger,项目名称:ovrride,代码行数:71,代码来源:woocommerce-smart-coupons.php
示例20: render_select2_ajax
/**
* 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 );
* }
*
|
请发表评论