diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 00000000000..c00a1ca9322 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1,3 @@ +src_dir: . +coverage_clover: ./tmp/clover.xml +json_path: ./tmp/coveralls-upload.json diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 00000000000..fe40783e6b0 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,11 @@ +filter: + excluded_paths: + - tests/* + - apigen/* + - includes/api/v1/* + - includes/libraries/* + +checks: + php: + code_rating: true + duplication: true diff --git a/.travis.yml b/.travis.yml index 386a12e1e57..7b140e2a793 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,10 @@ matrix: env: WP_VERSION=latest WP_MULTISITE=0 before_script: - - bash tests/install-wp-tests.sh woocommerce_test root '' localhost $WP_VERSION + - bash tests/bin/install.sh woocommerce_test root '' localhost $WP_VERSION + - bash tests/bin/travis.sh before -script: phpunit +script: phpunit -c phpunit.xml.dist + +after_script: + - bash tests/bin/travis.sh after diff --git a/README.md b/README.md index a7807f31b7a..09b56617d99 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# [WooCommerce](http://www.woothemes.com/woocommerce/) - [![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/) [![Build Status](https://api.travis-ci.org/woothemes/woocommerce.png?branch=master)](http://travis-ci.org/woothemes/woocommerce) +# [WooCommerce](http://www.woothemes.com/woocommerce/) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/) [![Build Status](https://api.travis-ci.org/woothemes/woocommerce.svg?branch=master)](http://travis-ci.org/woothemes/woocommerce) [![Coverage Status](https://img.shields.io/coveralls/woothemes/woocommerce.svg)](https://coveralls.io/r/woothemes/woocommerce) Welcome to the WooCommerce repository on GitHub. Here you can browse the source, look at open issues and keep track of development. We recommend all developers to follow the [WooCommerce development blog](http://develop.woothemes.com/woocommerce/) to stay up to date about everything happening in the project. You can also [follow @DevelopWC](https://twitter.com/DevelopWC) on Twitter for the latest development updates. @@ -7,11 +7,10 @@ If you are not a developer, please use the [WooCommerce plugin page](http://word ## Support This repository is not suitable for support. Please don't use our issue tracker for support requests, but for core WooCommerce issues only. Support can take place in the appropriate channels: -* The [public support forums](http://wordpress.org/support/plugin/woocommerce) on WordPress.org, where the community can help each other out. * The [WooThemes premium support portal](http://support.woothemes.com/) for customers who have purchased themes or extensions. +* [Our public HelpDesk](https://support.woothemes.com/hc/communities/public/topics) which is available for all WooCommerce users. Support requests in issues on this repository will be closed on sight. - ## Contributing to WooCommerce If you have a patch, or stumbled upon an issue with WooCommerce core, you can contribute this back to the code. Please read our [contributor guidelines](https://github.com/woothemes/woocommerce/blob/master/CONTRIBUTING.md) for more information how you can do this. diff --git a/assets/js/admin/meta-boxes-order.js b/assets/js/admin/meta-boxes-order.js index f86e70a6024..06f764d842d 100644 --- a/assets/js/admin/meta-boxes-order.js +++ b/assets/js/admin/meta-boxes-order.js @@ -186,15 +186,16 @@ jQuery( function ( $ ) { // When the refund qty is changed, increase or decrease costs .on( 'change', '.woocommerce_order_items input.refund_order_item_qty', function() { var $row = $( this ).closest( 'tr.item' ); - var qty = $( this ).val(); - var o_qty = $row.find( 'input.quantity' ).attr( 'data-qty' ); + var qty = $row.find( 'input.quantity' ).val(); + var refund_qty = $( this ).val(); var line_total = $( 'input.line_total', $row ); var refund_line_total = $( 'input.refund_line_total', $row ); // Totals - var unit_total = accounting.unformat( line_total.attr( 'data-total' ), woocommerce_admin.mon_decimal_point ); + var unit_total = accounting.unformat( line_total.attr( 'data-total' ), woocommerce_admin.mon_decimal_point ) / qty; + refund_line_total.val( - parseFloat( accounting.formatNumber( unit_total * qty, woocommerce_admin_meta_boxes.rounding_precision, '' ) ) + parseFloat( accounting.formatNumber( unit_total * refund_qty, woocommerce_admin_meta_boxes.rounding_precision, '' ) ) .toString() .replace( '.', woocommerce_admin.mon_decimal_point ) ); @@ -203,10 +204,11 @@ jQuery( function ( $ ) { $( 'td.line_tax', $row ).each( function() { var line_total_tax = $( 'input.line_tax', $( this ) ); var refund_line_total_tax = $( 'input.refund_line_tax', $( this ) ); - var unit_total_tax = accounting.unformat( line_total_tax.attr( 'data-total_tax' ), woocommerce_admin.mon_decimal_point ); + var unit_total_tax = accounting.unformat( line_total_tax.attr( 'data-total_tax' ), woocommerce_admin.mon_decimal_point ) / qty; + if ( 0 < unit_total_tax ) { refund_line_total_tax.val( - parseFloat( accounting.formatNumber( unit_total_tax * qty, woocommerce_admin_meta_boxes.rounding_precision, '' ) ) + parseFloat( accounting.formatNumber( unit_total_tax * refund_qty, woocommerce_admin_meta_boxes.rounding_precision, '' ) ) .toString() .replace( '.', woocommerce_admin.mon_decimal_point ) ); diff --git a/assets/js/admin/meta-boxes-order.min.js b/assets/js/admin/meta-boxes-order.min.js index 11591d06b57..6879a4a0e87 100644 --- a/assets/js/admin/meta-boxes-order.min.js +++ b/assets/js/admin/meta-boxes-order.min.js @@ -1 +1 @@ -jQuery(function(a){function b(){a("#woocommerce-order-items").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}})}function c(){a("#woocommerce-order-items").unblock()}function d(){a("#tiptip_holder").removeAttr("style"),a("#tiptip_arrow").removeAttr("style"),a(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200})}function e(){var e={order_id:woocommerce_admin_meta_boxes.post_id,action:"woocommerce_load_order_items",security:woocommerce_admin_meta_boxes.order_item_nonce};b(),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}})}a("#woocommerce-order-actions input, #woocommerce-order-actions a").click(function(){window.onbeforeunload=""}),a("a.edit_address").click(function(b){b.preventDefault(),a(this).hide(),a(this).closest(".order_data_column").find("div.address").hide(),a(this).closest(".order_data_column").find("div.edit_address").show()}),a("body").on("click","a.edit-order-item",function(){return a(this).closest("tr").find(".view").hide(),a(this).closest("tr").find(".edit").show(),a(this).hide(),a("button.add-line-item").click(),a("button.cancel-action").attr("data-reload",!0),!1}).on("click",".woocommerce_order_items a.delete-order-item",function(){var d=window.confirm(woocommerce_admin_meta_boxes.remove_item_notice);if(d){var e=a(this).closest("tr.item, tr.fee, tr.shipping"),f=e.attr("data-order_item_id");b();var g={order_item_ids:f,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:g,type:"POST",success:function(){e.remove(),c()}})}return!1}).on("click","#order_refunds .delete_refund",function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_delete_refund)){var c=a(this).closest("tr.refund"),d=c.attr("data-order_refund_id");b();var f={action:"woocommerce_delete_refund",refund_id:d,security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(){e()}})}return!1}).on("change",".woocommerce_order_items input.quantity",function(){var b=a(this).closest("tr.item"),c=a(this).val(),d=(a(this).attr("data-qty"),a("input.line_total",b)),e=a("input.line_subtotal",b),f=accounting.unformat(d.attr("data-total"),woocommerce_admin.mon_decimal_point);d.val(parseFloat(accounting.formatNumber(f*c,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point));var g=accounting.unformat(e.attr("data-subtotal"),woocommerce_admin.mon_decimal_point);e.val(parseFloat(accounting.formatNumber(g*c,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point)),a("td.line_tax",b).each(function(){var b=a("input.line_tax",a(this)),d=accounting.unformat(b.attr("data-total_tax"),woocommerce_admin.mon_decimal_point);d>0&&b.val(parseFloat(accounting.formatNumber(d*c,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point));var e=a("input.line_subtotal_tax",a(this)),f=accounting.unformat(e.attr("data-subtotal_tax"),woocommerce_admin.mon_decimal_point);f>0&&e.val(parseFloat(accounting.formatNumber(f*c,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point))}),a(this).trigger("quantity_changed")}).on("change",".woocommerce_order_items input.refund_order_item_qty",function(){var b=a(this).closest("tr.item"),c=a(this).val(),d=(b.find("input.quantity").attr("data-qty"),a("input.line_total",b)),e=a("input.refund_line_total",b),f=accounting.unformat(d.attr("data-total"),woocommerce_admin.mon_decimal_point);e.val(parseFloat(accounting.formatNumber(f*c,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point)),a("td.line_tax",b).each(function(){var b=a("input.line_tax",a(this)),d=a("input.refund_line_tax",a(this)),e=accounting.unformat(b.attr("data-total_tax"),woocommerce_admin.mon_decimal_point);e>0&&d.val(parseFloat(accounting.formatNumber(e*c,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point))}),a(this).trigger("refund_quantity_changed")}).on("change",".woocommerce_order_items .refund input",function(){var b=0,c=a(".woocommerce_order_items").find("tr.item, tr.fee, tr.shipping");c.each(function(){var c=a(this),d=c.find(".refund input:not(.refund_order_item_qty)");d.each(function(c,d){b+=parseFloat(accounting.unformat(a(d).val()||0,woocommerce_admin.mon_decimal_point))})}),a("#refund_amount").val(accounting.formatNumber(b,woocommerce_admin_meta_boxes.currency_format_num_decimals,"",woocommerce_admin.mon_decimal_point)).change()}).on("click",".woocommerce_order_items button.add_order_item_meta",function(){var d=a(this),e=d.closest("tr.item"),f={order_item_id:e.attr("data-order_item_id"),action:"woocommerce_add_order_item_meta",security:woocommerce_admin_meta_boxes.order_item_nonce};return b(),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(a){e.find("tbody.meta_items").append(a),c()}}),!1}).on("click",".woocommerce_order_items button.remove_order_item_meta",function(){if(window.confirm(woocommerce_admin_meta_boxes.remove_item_meta)){var d=a(this).closest("tr"),e={meta_id:d.attr("data-meta_id"),action:"woocommerce_remove_order_item_meta",security:woocommerce_admin_meta_boxes.order_item_nonce};b(),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(){d.hide(),c()}})}return!1}).on("keyup",".woocommerce_order_items .split-input input:eq(0)",function(){var b=a(this).next();(""===b.val()||b.is(".match-total"))&&b.val(a(this).val()).addClass("match-total")}).on("keyup",".woocommerce_order_items .split-input input:eq(0)",function(){a(this).removeClass("match-total")}),a("#woocommerce-order-items").on("click","button.add-line-item",function(){return a("div.wc-order-add-item").slideDown(),a("div.wc-order-bulk-actions").slideUp(),!1}).on("click","button.refund-items",function(){return a("div.wc-order-refund-items").slideDown(),a("div.wc-order-bulk-actions").slideUp(),a("div.wc-order-totals-items").slideUp(),a("#woocommerce-order-items div.refund").show(),a(".wc-order-edit-line-item .wc-order-edit-line-item-actions").hide(),!1}).on("click",".cancel-action",function(){return a(this).closest("div.wc-order-data-row").slideUp(),a("div.wc-order-bulk-actions").slideDown(),a("div.wc-order-totals-items").slideDown(),a("#woocommerce-order-items div.refund").hide(),a(".wc-order-edit-line-item .wc-order-edit-line-item-actions").show(),"true"===a(this).attr("data-reload")&&e(),!1}).on("click","button.add-order-item",function(){return a(this).WCBackboneModal({template:"#wc-modal-add-products"}),!1}).on("click","button.add-order-fee",function(){b();var d={action:"woocommerce_add_order_fee",order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,d,function(b){a("table.woocommerce_order_items tbody#order_fee_line_items").append(b),c()}),!1}).on("click","button.add-order-shipping",function(){b();var d={action:"woocommerce_add_order_shipping",order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,d,function(b){a("table.woocommerce_order_items tbody#order_shipping_line_items").append(b),c()}),!1}).on("click","button.add-order-tax",function(){return a(this).WCBackboneModal({template:"#wc-modal-add-tax"}),!1}).on("click","input.check-column",function(){a(this).is(":checked")?a("#woocommerce-order-items").find(".check-column input").attr("checked","checked"):a("#woocommerce-order-items").find(".check-column input").removeAttr("checked")}).on("click",".do_bulk_action",function(){var d=a(this).closest(".bulk-actions").find("select").val(),e=a("#woocommerce-order-items").find(".check-column input:checked"),f=[];if(a(e).each(function(){var b=a(this).closest("tr");b.attr("data-order_item_id")&&f.push(b.attr("data-order_item_id"))}),0===f.length)return void window.alert(woocommerce_admin_meta_boxes.i18n_select_items);if("delete"===d){if(window.confirm(woocommerce_admin_meta_boxes.remove_item_notice)){b();var g={order_item_ids:f,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:g,type:"POST",success:function(){a(e).each(function(){a(this).closest("tr").remove()}),c()}})}}else if("reduce_stock"===d){b();var h={};a(e).each(function(){var b=a(this).closest("tr.item, tr.fee"),c=b.find("input.quantity");h[b.attr("data-order_item_id")]=c.val()});var g={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:f,order_item_qty:h,action:"woocommerce_reduce_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:g,type:"POST",success:function(a){window.alert(a),c()}})}else if("increase_stock"===d){b();var h={};a(e).each(function(){var b=a(this).closest("tr.item, tr.fee"),c=b.find("input.quantity");h[b.attr("data-order_item_id")]=c.val()});var g={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:f,order_item_qty:h,action:"woocommerce_increase_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:g,type:"POST",success:function(a){window.alert(a),c()}})}return!1}).on("click","button.calculate-action",function(){if(window.confirm(woocommerce_admin_meta_boxes.calc_totals)){b();var c=0,d=0,e=0,f=a("#_order_discount").val()||"0";f=accounting.unformat(f.replace(",",".")),a(".woocommerce_order_items tr.shipping input.line_total").each(function(){var b=a(this).val()||"0";b=accounting.unformat(b,woocommerce_admin.mon_decimal_point),e+=parseFloat(b)}),a(".woocommerce_order_items input.line_tax").each(function(){var b=a(this).val()||"0";b=accounting.unformat(b,woocommerce_admin.mon_decimal_point),d+=parseFloat(b)}),a(".woocommerce_order_items tr.item, .woocommerce_order_items tr.fee").each(function(){var b=a(this).find("input.line_total").val()||"0";c+=accounting.unformat(b.replace(",","."))}),"yes"===woocommerce_admin_meta_boxes.round_at_subtotal&&(d=parseFloat(accounting.toFixed(d,woocommerce_admin_meta_boxes.rounding_precision))),a("#_order_total").val(accounting.formatNumber(c+d+e-f,woocommerce_admin_meta_boxes.currency_format_num_decimals,"",woocommerce_admin.mon_decimal_point)).change(),a("button.save-action").click()}return!1}).on("click","button.save-action",function(){var e={order_id:woocommerce_admin_meta_boxes.post_id,items:a("table.woocommerce_order_items :input[name], .wc-order-totals-items :input[name]").serialize(),action:"woocommerce_save_order_items",security:woocommerce_admin_meta_boxes.order_item_nonce};return b(),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}}),!1}).on("click","a.delete-order-tax",function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_delete_tax)){b();var e={action:"woocommerce_remove_order_tax",rate_id:a(this).attr("data-rate_id"),order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}})}return!1}).on("click","button.calculate-tax-action",function(){if(window.confirm(woocommerce_admin_meta_boxes.calc_line_taxes)){b();var e=a("#_shipping_country").val(),f=a("#_billing_country").val(),g=woocommerce_admin_meta_boxes.base_country,h="",i="",j="";e?(g=e,h=a("#_shipping_state").val(),i=a("#_shipping_postcode").val(),j=a("#_shipping_city").val()):f&&(g=f,h=a("#_billing_state").val(),i=a("#_billing_postcode").val(),j=a("#_billing_city").val());var k={action:"woocommerce_calc_line_taxes",order_id:woocommerce_admin_meta_boxes.post_id,items:a("table.woocommerce_order_items :input[name], .wc-order-totals-items :input[name]").serialize(),country:g,state:h,postcode:i,city:j,security:woocommerce_admin_meta_boxes.calc_totals_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:k,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}})}return!1}),a("body").on("change",".wc-order-refund-items #refund_amount",function(){var b=accounting.unformat(a(this).val(),woocommerce_admin.mon_decimal_point);a("button .wc-order-refund-amount .amount").text(accounting.formatMoney(b,{symbol:woocommerce_admin_meta_boxes.currency_format_symbol,decimal:woocommerce_admin_meta_boxes.currency_format_decimal_sep,thousand:woocommerce_admin_meta_boxes.currency_format_thousand_sep,precision:woocommerce_admin_meta_boxes.currency_format_num_decimals,format:woocommerce_admin_meta_boxes.currency_format}))}).on("click",".wc-order-refund-items button.do-api-refund, .wc-order-refund-items button.do-manual-refund",function(){if(b(),window.confirm(woocommerce_admin_meta_boxes.i18n_do_refund)){var d=a("input#refund_amount").val(),f=a("input#refund_reason").val(),g={},h={},i={};a(".refund input.refund_order_item_qty").each(function(b,c){a(c).closest("tr").data("order_item_id")&&c.value&&(g[a(c).closest("tr").data("order_item_id")]=c.value)}),a(".refund input.refund_line_total").each(function(b,c){a(c).closest("tr").data("order_item_id")&&(h[a(c).closest("tr").data("order_item_id")]=accounting.unformat(c.value,woocommerce_admin.mon_decimal_point))}),a(".refund input.refund_line_tax").each(function(b,c){if(a(c).closest("tr").data("order_item_id")){var d=a(c).data("tax_id");i[a(c).closest("tr").data("order_item_id")]||(i[a(c).closest("tr").data("order_item_id")]={}),i[a(c).closest("tr").data("order_item_id")][d]=accounting.unformat(c.value,woocommerce_admin.mon_decimal_point)}});var j={action:"woocommerce_refund_line_items",order_id:woocommerce_admin_meta_boxes.post_id,refund_amount:d,refund_reason:f,line_item_qtys:JSON.stringify(g,null,""),line_item_totals:JSON.stringify(h,null,""),line_item_tax_totals:JSON.stringify(i,null,""),api_refund:a(this).is(".do-api-refund"),restock_refunded_items:a("#restock_refunded_items:checked").size()?"true":"false",security:woocommerce_admin_meta_boxes.order_item_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,j,function(a){a===!0?e():a.error?(window.alert(a.error),c()):console.log(a)})}else c()}),a("body").on("wc_backbone_modal_response",function(e,f){if("#wc-modal-add-products"===f){var g=a("select#add_item_id").val();if(g){var h=g.length;b(),a.each(g,function(b,e){var f={action:"woocommerce_add_order_item",item_to_add:e,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,f,function(b){a("table.woocommerce_order_items tbody#order_line_items").append(b),--h||(a("select#add_item_id, #add_item_id_chosen .chosen-choices").css("border-color","").val(""),d(),a("select#add_item_id").trigger("chosen:updated"),c())})})}else a("select#add_item_id, #add_item_id_chosen .chosen-choices").css("border-color","red")}}),a("body").on("wc_backbone_modal_response",function(e,f){if("#wc-modal-add-tax"===f){var g=a("#manual_tax_rate_id").val(),h=a("input[name=add_order_tax]:checked").val();if(g&&(h=g),!h)return!1;var i=a(".order-tax-id").map(function(){return a(this).val()}).get();if(-1===a.inArray(h,i)){b();var j={action:"woocommerce_add_order_tax",rate_id:h,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:j,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}})}else window.alert(woocommerce_admin_meta_boxes.i18n_tax_rate_already_exists)}}),a("span.inline_total").closest(".totals_group").find("input").change(),a(".order_download_permissions").on("click","button.grant_access",function(){var b=a("select#grant_access_id").val();if(b){a(".order_download_permissions").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var c={action:"woocommerce_grant_access_to_download",product_ids:b,loop:a(".order_download_permissions .wc-metabox").size(),order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.grant_access_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,c,function(b){b?a(".order_download_permissions .wc-metaboxes").append(b):window.alert(woocommerce_admin_meta_boxes.i18n_download_permission_fail),a(".date-picker").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,showOn:"button",buttonImage:woocommerce_admin_meta_boxes.calendar_image,buttonImageOnly:!0}),a("#grant_access_id").val("").trigger("chosen:updated"),a(".order_download_permissions").unblock()}),!1}}).on("click","button.revoke_access",function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_permission_revoke)){var b=a(this).parent().parent(),c=a(this).attr("rel").split(",")[0],d=a(this).attr("rel").split(",")[1];if(c>0){a(b).block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var e={action:"woocommerce_revoke_access_to_download",product_id:c,download_id:d,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.revoke_access_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,e,function(){a(b).fadeOut("300",function(){a(b).remove()})})}else a(b).fadeOut("300",function(){a(b).remove()})}return!1}),a("button.load_customer_billing").on("click",function(){if(window.confirm(woocommerce_admin_meta_boxes.load_billing)){var b=a("#customer_user").val();if(!b)return window.alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var c={user_id:b,type_to_load:"billing",action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};a(this).closest(".edit_address").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:c,type:"POST",success:function(b){var c=b;c&&(a("input#_billing_first_name").val(c.billing_first_name),a("input#_billing_last_name").val(c.billing_last_name),a("input#_billing_company").val(c.billing_company),a("input#_billing_address_1").val(c.billing_address_1),a("input#_billing_address_2").val(c.billing_address_2),a("input#_billing_city").val(c.billing_city),a("input#_billing_postcode").val(c.billing_postcode),a("#_billing_country").val(c.billing_country),a("input#_billing_state").val(c.billing_state),a("input#_billing_email").val(c.billing_email),a("input#_billing_phone").val(c.billing_phone)),a(".edit_address").unblock()}})}return!1}),a("button.load_customer_shipping").on("click",function(){if(window.confirm(woocommerce_admin_meta_boxes.load_shipping)){var b=a("#customer_user").val();if(!b)return window.alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var c={user_id:b,type_to_load:"shipping",action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};a(this).closest(".edit_address").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:c,type:"POST",success:function(b){var c=b;c&&(a("input#_shipping_first_name").val(c.shipping_first_name),a("input#_shipping_last_name").val(c.shipping_last_name),a("input#_shipping_company").val(c.shipping_company),a("input#_shipping_address_1").val(c.shipping_address_1),a("input#_shipping_address_2").val(c.shipping_address_2),a("input#_shipping_city").val(c.shipping_city),a("input#_shipping_postcode").val(c.shipping_postcode),a("#_shipping_country").val(c.shipping_country),a("input#_shipping_state").val(c.shipping_state)),a(".edit_address").unblock()}})}return!1}),a("button.billing-same-as-shipping").on("click",function(){return window.confirm(woocommerce_admin_meta_boxes.copy_billing)&&(a("input#_shipping_first_name").val(a("input#_billing_first_name").val()),a("input#_shipping_last_name").val(a("input#_billing_last_name").val()),a("input#_shipping_company").val(a("input#_billing_company").val()),a("input#_shipping_address_1").val(a("input#_billing_address_1").val()),a("input#_shipping_address_2").val(a("input#_billing_address_2").val()),a("input#_shipping_city").val(a("input#_billing_city").val()),a("input#_shipping_postcode").val(a("input#_billing_postcode").val()),a("#_shipping_country").val(a("#_billing_country").val()),a("input#_shipping_state").val(a("input#_billing_state").val())),!1}),a(".totals_group").on("click","a.add_total_row",function(){return a(this).closest(".totals_group").find(".total_rows").append(a(this).data("row")),!1}),a(".total_rows").on("click","a.delete_total_row",function(){var b=a(this).closest(".total_row"),c=b.attr("data-order_item_id");return c?b.append('').hide():b.remove(),!1}),a("#woocommerce-order-notes").on("click","a.add_note",function(){if(a("textarea#add_order_note").val()){a("#woocommerce-order-notes").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var b={action:"woocommerce_add_order_note",post_id:woocommerce_admin_meta_boxes.post_id,note:a("textarea#add_order_note").val(),note_type:a("select#order_note_type").val(),security:woocommerce_admin_meta_boxes.add_order_note_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,b,function(b){a("ul.order_notes").prepend(b),a("#woocommerce-order-notes").unblock(),a("#add_order_note").val("")}),!1}}).on("click","a.delete_note",function(){var b=a(this).closest("li.note");a(b).block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var c={action:"woocommerce_delete_order_note",note_id:a(b).attr("rel"),security:woocommerce_admin_meta_boxes.delete_order_note_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,c,function(){a(b).remove()}),!1})}); \ No newline at end of file +jQuery(function(a){function b(){a("#woocommerce-order-items").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}})}function c(){a("#woocommerce-order-items").unblock()}function d(){a("#tiptip_holder").removeAttr("style"),a("#tiptip_arrow").removeAttr("style"),a(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200})}function e(){var e={order_id:woocommerce_admin_meta_boxes.post_id,action:"woocommerce_load_order_items",security:woocommerce_admin_meta_boxes.order_item_nonce};b(),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}})}a("#woocommerce-order-actions input, #woocommerce-order-actions a").click(function(){window.onbeforeunload=""}),a("a.edit_address").click(function(b){b.preventDefault(),a(this).hide(),a(this).closest(".order_data_column").find("div.address").hide(),a(this).closest(".order_data_column").find("div.edit_address").show()}),a("body").on("click","a.edit-order-item",function(){return a(this).closest("tr").find(".view").hide(),a(this).closest("tr").find(".edit").show(),a(this).hide(),a("button.add-line-item").click(),a("button.cancel-action").attr("data-reload",!0),!1}).on("click",".woocommerce_order_items a.delete-order-item",function(){var d=window.confirm(woocommerce_admin_meta_boxes.remove_item_notice);if(d){var e=a(this).closest("tr.item, tr.fee, tr.shipping"),f=e.attr("data-order_item_id");b();var g={order_item_ids:f,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:g,type:"POST",success:function(){e.remove(),c()}})}return!1}).on("click","#order_refunds .delete_refund",function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_delete_refund)){var c=a(this).closest("tr.refund"),d=c.attr("data-order_refund_id");b();var f={action:"woocommerce_delete_refund",refund_id:d,security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(){e()}})}return!1}).on("change",".woocommerce_order_items input.quantity",function(){var b=a(this).closest("tr.item"),c=a(this).val(),d=(a(this).attr("data-qty"),a("input.line_total",b)),e=a("input.line_subtotal",b),f=accounting.unformat(d.attr("data-total"),woocommerce_admin.mon_decimal_point);d.val(parseFloat(accounting.formatNumber(f*c,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point));var g=accounting.unformat(e.attr("data-subtotal"),woocommerce_admin.mon_decimal_point);e.val(parseFloat(accounting.formatNumber(g*c,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point)),a("td.line_tax",b).each(function(){var b=a("input.line_tax",a(this)),d=accounting.unformat(b.attr("data-total_tax"),woocommerce_admin.mon_decimal_point);d>0&&b.val(parseFloat(accounting.formatNumber(d*c,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point));var e=a("input.line_subtotal_tax",a(this)),f=accounting.unformat(e.attr("data-subtotal_tax"),woocommerce_admin.mon_decimal_point);f>0&&e.val(parseFloat(accounting.formatNumber(f*c,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point))}),a(this).trigger("quantity_changed")}).on("change",".woocommerce_order_items input.refund_order_item_qty",function(){var b=a(this).closest("tr.item"),c=b.find("input.quantity").val(),d=a(this).val(),e=a("input.line_total",b),f=a("input.refund_line_total",b),g=accounting.unformat(e.attr("data-total"),woocommerce_admin.mon_decimal_point)/c;f.val(parseFloat(accounting.formatNumber(g*d,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point)),a("td.line_tax",b).each(function(){var b=a("input.line_tax",a(this)),e=a("input.refund_line_tax",a(this)),f=accounting.unformat(b.attr("data-total_tax"),woocommerce_admin.mon_decimal_point)/c;f>0&&e.val(parseFloat(accounting.formatNumber(f*d,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point))}),a(this).trigger("refund_quantity_changed")}).on("change",".woocommerce_order_items .refund input",function(){var b=0,c=a(".woocommerce_order_items").find("tr.item, tr.fee, tr.shipping");c.each(function(){var c=a(this),d=c.find(".refund input:not(.refund_order_item_qty)");d.each(function(c,d){b+=parseFloat(accounting.unformat(a(d).val()||0,woocommerce_admin.mon_decimal_point))})}),a("#refund_amount").val(accounting.formatNumber(b,woocommerce_admin_meta_boxes.currency_format_num_decimals,"",woocommerce_admin.mon_decimal_point)).change()}).on("click",".woocommerce_order_items button.add_order_item_meta",function(){var d=a(this),e=d.closest("tr.item"),f={order_item_id:e.attr("data-order_item_id"),action:"woocommerce_add_order_item_meta",security:woocommerce_admin_meta_boxes.order_item_nonce};return b(),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(a){e.find("tbody.meta_items").append(a),c()}}),!1}).on("click",".woocommerce_order_items button.remove_order_item_meta",function(){if(window.confirm(woocommerce_admin_meta_boxes.remove_item_meta)){var d=a(this).closest("tr"),e={meta_id:d.attr("data-meta_id"),action:"woocommerce_remove_order_item_meta",security:woocommerce_admin_meta_boxes.order_item_nonce};b(),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(){d.hide(),c()}})}return!1}).on("keyup",".woocommerce_order_items .split-input input:eq(0)",function(){var b=a(this).next();(""===b.val()||b.is(".match-total"))&&b.val(a(this).val()).addClass("match-total")}).on("keyup",".woocommerce_order_items .split-input input:eq(0)",function(){a(this).removeClass("match-total")}),a("#woocommerce-order-items").on("click","button.add-line-item",function(){return a("div.wc-order-add-item").slideDown(),a("div.wc-order-bulk-actions").slideUp(),!1}).on("click","button.refund-items",function(){return a("div.wc-order-refund-items").slideDown(),a("div.wc-order-bulk-actions").slideUp(),a("div.wc-order-totals-items").slideUp(),a("#woocommerce-order-items div.refund").show(),a(".wc-order-edit-line-item .wc-order-edit-line-item-actions").hide(),!1}).on("click",".cancel-action",function(){return a(this).closest("div.wc-order-data-row").slideUp(),a("div.wc-order-bulk-actions").slideDown(),a("div.wc-order-totals-items").slideDown(),a("#woocommerce-order-items div.refund").hide(),a(".wc-order-edit-line-item .wc-order-edit-line-item-actions").show(),"true"===a(this).attr("data-reload")&&e(),!1}).on("click","button.add-order-item",function(){return a(this).WCBackboneModal({template:"#wc-modal-add-products"}),!1}).on("click","button.add-order-fee",function(){b();var d={action:"woocommerce_add_order_fee",order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,d,function(b){a("table.woocommerce_order_items tbody#order_fee_line_items").append(b),c()}),!1}).on("click","button.add-order-shipping",function(){b();var d={action:"woocommerce_add_order_shipping",order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,d,function(b){a("table.woocommerce_order_items tbody#order_shipping_line_items").append(b),c()}),!1}).on("click","button.add-order-tax",function(){return a(this).WCBackboneModal({template:"#wc-modal-add-tax"}),!1}).on("click","input.check-column",function(){a(this).is(":checked")?a("#woocommerce-order-items").find(".check-column input").attr("checked","checked"):a("#woocommerce-order-items").find(".check-column input").removeAttr("checked")}).on("click",".do_bulk_action",function(){var d=a(this).closest(".bulk-actions").find("select").val(),e=a("#woocommerce-order-items").find(".check-column input:checked"),f=[];if(a(e).each(function(){var b=a(this).closest("tr");b.attr("data-order_item_id")&&f.push(b.attr("data-order_item_id"))}),0===f.length)return void window.alert(woocommerce_admin_meta_boxes.i18n_select_items);if("delete"===d){if(window.confirm(woocommerce_admin_meta_boxes.remove_item_notice)){b();var g={order_item_ids:f,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:g,type:"POST",success:function(){a(e).each(function(){a(this).closest("tr").remove()}),c()}})}}else if("reduce_stock"===d){b();var h={};a(e).each(function(){var b=a(this).closest("tr.item, tr.fee"),c=b.find("input.quantity");h[b.attr("data-order_item_id")]=c.val()});var g={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:f,order_item_qty:h,action:"woocommerce_reduce_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:g,type:"POST",success:function(a){window.alert(a),c()}})}else if("increase_stock"===d){b();var h={};a(e).each(function(){var b=a(this).closest("tr.item, tr.fee"),c=b.find("input.quantity");h[b.attr("data-order_item_id")]=c.val()});var g={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:f,order_item_qty:h,action:"woocommerce_increase_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:g,type:"POST",success:function(a){window.alert(a),c()}})}return!1}).on("click","button.calculate-action",function(){if(window.confirm(woocommerce_admin_meta_boxes.calc_totals)){b();var c=0,d=0,e=0,f=a("#_order_discount").val()||"0";f=accounting.unformat(f.replace(",",".")),a(".woocommerce_order_items tr.shipping input.line_total").each(function(){var b=a(this).val()||"0";b=accounting.unformat(b,woocommerce_admin.mon_decimal_point),e+=parseFloat(b)}),a(".woocommerce_order_items input.line_tax").each(function(){var b=a(this).val()||"0";b=accounting.unformat(b,woocommerce_admin.mon_decimal_point),d+=parseFloat(b)}),a(".woocommerce_order_items tr.item, .woocommerce_order_items tr.fee").each(function(){var b=a(this).find("input.line_total").val()||"0";c+=accounting.unformat(b.replace(",","."))}),"yes"===woocommerce_admin_meta_boxes.round_at_subtotal&&(d=parseFloat(accounting.toFixed(d,woocommerce_admin_meta_boxes.rounding_precision))),a("#_order_total").val(accounting.formatNumber(c+d+e-f,woocommerce_admin_meta_boxes.currency_format_num_decimals,"",woocommerce_admin.mon_decimal_point)).change(),a("button.save-action").click()}return!1}).on("click","button.save-action",function(){var e={order_id:woocommerce_admin_meta_boxes.post_id,items:a("table.woocommerce_order_items :input[name], .wc-order-totals-items :input[name]").serialize(),action:"woocommerce_save_order_items",security:woocommerce_admin_meta_boxes.order_item_nonce};return b(),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}}),!1}).on("click","a.delete-order-tax",function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_delete_tax)){b();var e={action:"woocommerce_remove_order_tax",rate_id:a(this).attr("data-rate_id"),order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}})}return!1}).on("click","button.calculate-tax-action",function(){if(window.confirm(woocommerce_admin_meta_boxes.calc_line_taxes)){b();var e=a("#_shipping_country").val(),f=a("#_billing_country").val(),g=woocommerce_admin_meta_boxes.base_country,h="",i="",j="";e?(g=e,h=a("#_shipping_state").val(),i=a("#_shipping_postcode").val(),j=a("#_shipping_city").val()):f&&(g=f,h=a("#_billing_state").val(),i=a("#_billing_postcode").val(),j=a("#_billing_city").val());var k={action:"woocommerce_calc_line_taxes",order_id:woocommerce_admin_meta_boxes.post_id,items:a("table.woocommerce_order_items :input[name], .wc-order-totals-items :input[name]").serialize(),country:g,state:h,postcode:i,city:j,security:woocommerce_admin_meta_boxes.calc_totals_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:k,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}})}return!1}),a("body").on("change",".wc-order-refund-items #refund_amount",function(){var b=accounting.unformat(a(this).val(),woocommerce_admin.mon_decimal_point);a("button .wc-order-refund-amount .amount").text(accounting.formatMoney(b,{symbol:woocommerce_admin_meta_boxes.currency_format_symbol,decimal:woocommerce_admin_meta_boxes.currency_format_decimal_sep,thousand:woocommerce_admin_meta_boxes.currency_format_thousand_sep,precision:woocommerce_admin_meta_boxes.currency_format_num_decimals,format:woocommerce_admin_meta_boxes.currency_format}))}).on("click",".wc-order-refund-items button.do-api-refund, .wc-order-refund-items button.do-manual-refund",function(){if(b(),window.confirm(woocommerce_admin_meta_boxes.i18n_do_refund)){var d=a("input#refund_amount").val(),f=a("input#refund_reason").val(),g={},h={},i={};a(".refund input.refund_order_item_qty").each(function(b,c){a(c).closest("tr").data("order_item_id")&&c.value&&(g[a(c).closest("tr").data("order_item_id")]=c.value)}),a(".refund input.refund_line_total").each(function(b,c){a(c).closest("tr").data("order_item_id")&&(h[a(c).closest("tr").data("order_item_id")]=accounting.unformat(c.value,woocommerce_admin.mon_decimal_point))}),a(".refund input.refund_line_tax").each(function(b,c){if(a(c).closest("tr").data("order_item_id")){var d=a(c).data("tax_id");i[a(c).closest("tr").data("order_item_id")]||(i[a(c).closest("tr").data("order_item_id")]={}),i[a(c).closest("tr").data("order_item_id")][d]=accounting.unformat(c.value,woocommerce_admin.mon_decimal_point)}});var j={action:"woocommerce_refund_line_items",order_id:woocommerce_admin_meta_boxes.post_id,refund_amount:d,refund_reason:f,line_item_qtys:JSON.stringify(g,null,""),line_item_totals:JSON.stringify(h,null,""),line_item_tax_totals:JSON.stringify(i,null,""),api_refund:a(this).is(".do-api-refund"),restock_refunded_items:a("#restock_refunded_items:checked").size()?"true":"false",security:woocommerce_admin_meta_boxes.order_item_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,j,function(a){a===!0?e():a.error?(window.alert(a.error),c()):console.log(a)})}else c()}),a("body").on("wc_backbone_modal_response",function(e,f){if("#wc-modal-add-products"===f){var g=a("select#add_item_id").val();if(g){var h=g.length;b(),a.each(g,function(b,e){var f={action:"woocommerce_add_order_item",item_to_add:e,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,f,function(b){a("table.woocommerce_order_items tbody#order_line_items").append(b),--h||(a("select#add_item_id, #add_item_id_chosen .chosen-choices").css("border-color","").val(""),d(),a("select#add_item_id").trigger("chosen:updated"),c())})})}else a("select#add_item_id, #add_item_id_chosen .chosen-choices").css("border-color","red")}}),a("body").on("wc_backbone_modal_response",function(e,f){if("#wc-modal-add-tax"===f){var g=a("#manual_tax_rate_id").val(),h=a("input[name=add_order_tax]:checked").val();if(g&&(h=g),!h)return!1;var i=a(".order-tax-id").map(function(){return a(this).val()}).get();if(-1===a.inArray(h,i)){b();var j={action:"woocommerce_add_order_tax",rate_id:h,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:j,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}})}else window.alert(woocommerce_admin_meta_boxes.i18n_tax_rate_already_exists)}}),a("span.inline_total").closest(".totals_group").find("input").change(),a(".order_download_permissions").on("click","button.grant_access",function(){var b=a("select#grant_access_id").val();if(b){a(".order_download_permissions").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var c={action:"woocommerce_grant_access_to_download",product_ids:b,loop:a(".order_download_permissions .wc-metabox").size(),order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.grant_access_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,c,function(b){b?a(".order_download_permissions .wc-metaboxes").append(b):window.alert(woocommerce_admin_meta_boxes.i18n_download_permission_fail),a(".date-picker").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,showOn:"button",buttonImage:woocommerce_admin_meta_boxes.calendar_image,buttonImageOnly:!0}),a("#grant_access_id").val("").trigger("chosen:updated"),a(".order_download_permissions").unblock()}),!1}}).on("click","button.revoke_access",function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_permission_revoke)){var b=a(this).parent().parent(),c=a(this).attr("rel").split(",")[0],d=a(this).attr("rel").split(",")[1];if(c>0){a(b).block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var e={action:"woocommerce_revoke_access_to_download",product_id:c,download_id:d,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.revoke_access_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,e,function(){a(b).fadeOut("300",function(){a(b).remove()})})}else a(b).fadeOut("300",function(){a(b).remove()})}return!1}),a("button.load_customer_billing").on("click",function(){if(window.confirm(woocommerce_admin_meta_boxes.load_billing)){var b=a("#customer_user").val();if(!b)return window.alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var c={user_id:b,type_to_load:"billing",action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};a(this).closest(".edit_address").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:c,type:"POST",success:function(b){var c=b;c&&(a("input#_billing_first_name").val(c.billing_first_name),a("input#_billing_last_name").val(c.billing_last_name),a("input#_billing_company").val(c.billing_company),a("input#_billing_address_1").val(c.billing_address_1),a("input#_billing_address_2").val(c.billing_address_2),a("input#_billing_city").val(c.billing_city),a("input#_billing_postcode").val(c.billing_postcode),a("#_billing_country").val(c.billing_country),a("input#_billing_state").val(c.billing_state),a("input#_billing_email").val(c.billing_email),a("input#_billing_phone").val(c.billing_phone)),a(".edit_address").unblock()}})}return!1}),a("button.load_customer_shipping").on("click",function(){if(window.confirm(woocommerce_admin_meta_boxes.load_shipping)){var b=a("#customer_user").val();if(!b)return window.alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var c={user_id:b,type_to_load:"shipping",action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};a(this).closest(".edit_address").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:c,type:"POST",success:function(b){var c=b;c&&(a("input#_shipping_first_name").val(c.shipping_first_name),a("input#_shipping_last_name").val(c.shipping_last_name),a("input#_shipping_company").val(c.shipping_company),a("input#_shipping_address_1").val(c.shipping_address_1),a("input#_shipping_address_2").val(c.shipping_address_2),a("input#_shipping_city").val(c.shipping_city),a("input#_shipping_postcode").val(c.shipping_postcode),a("#_shipping_country").val(c.shipping_country),a("input#_shipping_state").val(c.shipping_state)),a(".edit_address").unblock()}})}return!1}),a("button.billing-same-as-shipping").on("click",function(){return window.confirm(woocommerce_admin_meta_boxes.copy_billing)&&(a("input#_shipping_first_name").val(a("input#_billing_first_name").val()),a("input#_shipping_last_name").val(a("input#_billing_last_name").val()),a("input#_shipping_company").val(a("input#_billing_company").val()),a("input#_shipping_address_1").val(a("input#_billing_address_1").val()),a("input#_shipping_address_2").val(a("input#_billing_address_2").val()),a("input#_shipping_city").val(a("input#_billing_city").val()),a("input#_shipping_postcode").val(a("input#_billing_postcode").val()),a("#_shipping_country").val(a("#_billing_country").val()),a("input#_shipping_state").val(a("input#_billing_state").val())),!1}),a(".totals_group").on("click","a.add_total_row",function(){return a(this).closest(".totals_group").find(".total_rows").append(a(this).data("row")),!1}),a(".total_rows").on("click","a.delete_total_row",function(){var b=a(this).closest(".total_row"),c=b.attr("data-order_item_id");return c?b.append('').hide():b.remove(),!1}),a("#woocommerce-order-notes").on("click","a.add_note",function(){if(a("textarea#add_order_note").val()){a("#woocommerce-order-notes").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var b={action:"woocommerce_add_order_note",post_id:woocommerce_admin_meta_boxes.post_id,note:a("textarea#add_order_note").val(),note_type:a("select#order_note_type").val(),security:woocommerce_admin_meta_boxes.add_order_note_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,b,function(b){a("ul.order_notes").prepend(b),a("#woocommerce-order-notes").unblock(),a("#add_order_note").val("")}),!1}}).on("click","a.delete_note",function(){var b=a(this).closest("li.note");a(b).block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var c={action:"woocommerce_delete_order_note",note_id:a(b).attr("rel"),security:woocommerce_admin_meta_boxes.delete_order_note_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,c,function(){a(b).remove()}),!1})}); \ No newline at end of file diff --git a/i18n/languages/woocommerce-admin.pot b/i18n/languages/woocommerce-admin.pot index 376c7de899e..0baa2314523 100644 --- a/i18n/languages/woocommerce-admin.pot +++ b/i18n/languages/woocommerce-admin.pot @@ -2,16 +2,16 @@ # This file is distributed under the same license as the WooCommerce package. msgid "" msgstr "" -"Project-Id-Version: WooCommerce 2.2.0-bleeding Admin\n" +"Project-Id-Version: WooCommerce 2.2.0-RC1 Admin\n" "Report-Msgid-Bugs-To: https://github.com/woothemes/woocommerce/issues\n" -"POT-Creation-Date: 2014-09-04 14:14:15+00:00\n" +"POT-Creation-Date: 2014-09-08 15:44:12+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "PO-Revision-Date: 2014-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" -"X-Generator: grunt-wp-i18n 0.4.7\n" +"X-Generator: grunt-wp-i18n 0.4.8\n" #. Plugin Name of the plugin/theme msgid "WooCommerce" @@ -205,7 +205,7 @@ msgstr "" #: includes/admin/class-wc-admin-assets.php:186 #: includes/admin/class-wc-admin-post-types.php:122 -#: includes/admin/class-wc-admin-post-types.php:1952 +#: includes/admin/class-wc-admin-post-types.php:1954 #: includes/admin/views/html-bulk-edit-product.php:181 #: includes/admin/views/html-quick-edit-product.php:139 msgid "Featured" @@ -343,7 +343,7 @@ msgstr "" #: includes/admin/class-wc-admin-attributes.php:321 #: includes/admin/class-wc-admin-post-types.php:211 -#: includes/admin/class-wc-admin-post-types.php:1956 +#: includes/admin/class-wc-admin-post-types.php:1958 #: includes/admin/meta-boxes/class-wc-meta-box-order-data.php:215 #: includes/admin/meta-boxes/class-wc-meta-box-order-data.php:294 #: includes/admin/meta-boxes/views/html-order-items.php:202 @@ -488,9 +488,9 @@ msgstr "" #: includes/admin/class-wc-admin-help.php:52 msgid "" -"After reading the documentation, for further assistance " -"you can use the community forum, or if you have access " -"as a WooThemes customer, our support desk." +"After %sreading the documentation%s, for further assistance you can use our " +"%scommunity forum%s if you get stuck. For help with premium add-ons from " +"WooThemes, or if you are a WooThemes customer, you can %suse our helpdesk%s." msgstr "" #: includes/admin/class-wc-admin-help.php:54 @@ -508,11 +508,11 @@ msgid "System Status" msgstr "" #: includes/admin/class-wc-admin-help.php:56 -msgid "Community Support" +msgid "WooThemes Community Support" msgstr "" #: includes/admin/class-wc-admin-help.php:56 -msgid "Customer Support" +msgid "WooThemes Customer Support" msgstr "" #: includes/admin/class-wc-admin-help.php:62 @@ -880,14 +880,14 @@ msgid "External/Affiliate" msgstr "" #: includes/admin/class-wc-admin-post-types.php:286 -#: includes/admin/class-wc-admin-post-types.php:1408 +#: includes/admin/class-wc-admin-post-types.php:1410 #: includes/admin/meta-boxes/class-wc-meta-box-product-data.php:57 #: includes/admin/meta-boxes/views/html-variation-admin.php:235 msgid "Virtual" msgstr "" #: includes/admin/class-wc-admin-post-types.php:288 -#: includes/admin/class-wc-admin-post-types.php:1400 +#: includes/admin/class-wc-admin-post-types.php:1402 #: includes/admin/meta-boxes/class-wc-meta-box-product-data.php:64 #: includes/admin/meta-boxes/views/html-variation-admin.php:233 msgid "Downloadable" @@ -1028,247 +1028,247 @@ msgstr "" msgid "Sort Products" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1136 -#: includes/admin/class-wc-admin-post-types.php:1137 +#: includes/admin/class-wc-admin-post-types.php:1138 +#: includes/admin/class-wc-admin-post-types.php:1139 msgid "Mark processing" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1139 -#: includes/admin/class-wc-admin-post-types.php:1140 +#: includes/admin/class-wc-admin-post-types.php:1141 +#: includes/admin/class-wc-admin-post-types.php:1142 msgid "Mark on-hold" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1142 -#: includes/admin/class-wc-admin-post-types.php:1143 +#: includes/admin/class-wc-admin-post-types.php:1144 +#: includes/admin/class-wc-admin-post-types.php:1145 msgid "Mark complete" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1184 +#: includes/admin/class-wc-admin-post-types.php:1186 msgid "Order status changed by bulk edit:" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1206 +#: includes/admin/class-wc-admin-post-types.php:1208 msgid "Order status changed." msgid_plural "%s order statuses changed." msgstr[0] "" msgstr[1] "" -#: includes/admin/class-wc-admin-post-types.php:1360 +#: includes/admin/class-wc-admin-post-types.php:1362 msgid "Show all product types" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1373 +#: includes/admin/class-wc-admin-post-types.php:1375 #: includes/admin/meta-boxes/class-wc-meta-box-product-data.php:40 msgid "Grouped product" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1376 +#: includes/admin/class-wc-admin-post-types.php:1378 #: includes/admin/meta-boxes/class-wc-meta-box-product-data.php:41 msgid "External/Affiliate product" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1379 +#: includes/admin/class-wc-admin-post-types.php:1381 #: includes/admin/meta-boxes/class-wc-meta-box-product-data.php:42 msgid "Variable product" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1382 +#: includes/admin/class-wc-admin-post-types.php:1384 #: includes/admin/meta-boxes/class-wc-meta-box-product-data.php:39 msgid "Simple product" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1423 +#: includes/admin/class-wc-admin-post-types.php:1425 msgid "Show all types" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1451 -#: includes/admin/class-wc-admin-post-types.php:1473 +#: includes/admin/class-wc-admin-post-types.php:1453 +#: includes/admin/class-wc-admin-post-types.php:1475 msgid "Show all customers" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1630 +#: includes/admin/class-wc-admin-post-types.php:1632 msgid "Product updated. View Product" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1631 -#: includes/admin/class-wc-admin-post-types.php:1646 -#: includes/admin/class-wc-admin-post-types.php:1661 +#: includes/admin/class-wc-admin-post-types.php:1633 +#: includes/admin/class-wc-admin-post-types.php:1648 +#: includes/admin/class-wc-admin-post-types.php:1663 msgid "Custom field updated." msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1632 -#: includes/admin/class-wc-admin-post-types.php:1647 -#: includes/admin/class-wc-admin-post-types.php:1662 +#: includes/admin/class-wc-admin-post-types.php:1634 +#: includes/admin/class-wc-admin-post-types.php:1649 +#: includes/admin/class-wc-admin-post-types.php:1664 msgid "Custom field deleted." msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1633 +#: includes/admin/class-wc-admin-post-types.php:1635 msgid "Product updated." msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1634 +#: includes/admin/class-wc-admin-post-types.php:1636 msgid "Product restored to revision from %s" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1635 +#: includes/admin/class-wc-admin-post-types.php:1637 msgid "Product published. View Product" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1636 +#: includes/admin/class-wc-admin-post-types.php:1638 msgid "Product saved." msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1637 +#: includes/admin/class-wc-admin-post-types.php:1639 msgid "Product submitted. Preview Product" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1638 +#: includes/admin/class-wc-admin-post-types.php:1640 msgid "" "Product scheduled for: %1$s. Preview Product" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1639 -#: includes/admin/class-wc-admin-post-types.php:1654 -#: includes/admin/class-wc-admin-post-types.php:1669 +#: includes/admin/class-wc-admin-post-types.php:1641 +#: includes/admin/class-wc-admin-post-types.php:1656 +#: includes/admin/class-wc-admin-post-types.php:1671 msgid "M j, Y @ G:i" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1640 +#: includes/admin/class-wc-admin-post-types.php:1642 msgid "Product draft updated. Preview Product" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1645 -#: includes/admin/class-wc-admin-post-types.php:1648 +#: includes/admin/class-wc-admin-post-types.php:1647 #: includes/admin/class-wc-admin-post-types.php:1650 +#: includes/admin/class-wc-admin-post-types.php:1652 msgid "Order updated." msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1649 +#: includes/admin/class-wc-admin-post-types.php:1651 msgid "Order restored to revision from %s" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1651 +#: includes/admin/class-wc-admin-post-types.php:1653 msgid "Order saved." msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1652 +#: includes/admin/class-wc-admin-post-types.php:1654 msgid "Order submitted." msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1653 +#: includes/admin/class-wc-admin-post-types.php:1655 msgid "Order scheduled for: %1$s." msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1655 +#: includes/admin/class-wc-admin-post-types.php:1657 msgid "Order draft updated." msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1660 -#: includes/admin/class-wc-admin-post-types.php:1663 +#: includes/admin/class-wc-admin-post-types.php:1662 #: includes/admin/class-wc-admin-post-types.php:1665 +#: includes/admin/class-wc-admin-post-types.php:1667 msgid "Coupon updated." msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1664 +#: includes/admin/class-wc-admin-post-types.php:1666 msgid "Coupon restored to revision from %s" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1666 +#: includes/admin/class-wc-admin-post-types.php:1668 msgid "Coupon saved." msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1667 +#: includes/admin/class-wc-admin-post-types.php:1669 msgid "Coupon submitted." msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1668 +#: includes/admin/class-wc-admin-post-types.php:1670 msgid "Coupon scheduled for: %1$s." msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1670 +#: includes/admin/class-wc-admin-post-types.php:1672 msgid "Coupon draft updated." msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1852 +#: includes/admin/class-wc-admin-post-types.php:1854 msgid "Product Image" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1854 +#: includes/admin/class-wc-admin-post-types.php:1856 msgid "Remove product image" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1856 -#: includes/admin/class-wc-admin-post-types.php:1870 -#: includes/admin/class-wc-admin-post-types.php:1871 +#: includes/admin/class-wc-admin-post-types.php:1858 +#: includes/admin/class-wc-admin-post-types.php:1872 +#: includes/admin/class-wc-admin-post-types.php:1873 msgid "Set product image" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1884 +#: includes/admin/class-wc-admin-post-types.php:1886 msgid "Product name" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1887 +#: includes/admin/class-wc-admin-post-types.php:1889 msgid "Coupon code" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1900 +#: includes/admin/class-wc-admin-post-types.php:1902 msgid "Description (optional)" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1917 +#: includes/admin/class-wc-admin-post-types.php:1919 msgid "Insert into %s" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1918 +#: includes/admin/class-wc-admin-post-types.php:1920 msgid "Uploaded to this %s" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1941 +#: includes/admin/class-wc-admin-post-types.php:1943 msgid "Catalog/search" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1942 +#: includes/admin/class-wc-admin-post-types.php:1944 #: includes/admin/views/html-bulk-edit-product.php:169 #: includes/admin/views/html-quick-edit-product.php:126 msgid "Catalog" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1943 +#: includes/admin/class-wc-admin-post-types.php:1945 #: includes/admin/views/html-bulk-edit-product.php:170 #: includes/admin/views/html-quick-edit-product.php:127 msgid "Search" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1944 +#: includes/admin/class-wc-admin-post-types.php:1946 #: includes/admin/views/html-bulk-edit-product.php:171 #: includes/admin/views/html-quick-edit-product.php:128 msgid "Hidden" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1948 +#: includes/admin/class-wc-admin-post-types.php:1950 msgid "Catalog visibility:" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1964 +#: includes/admin/class-wc-admin-post-types.php:1966 msgid "" "Define the loops this product should be visible in. The product will still " "be accessible directly." msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1970 +#: includes/admin/class-wc-admin-post-types.php:1972 msgid "Enable this option to feature this product." msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1972 +#: includes/admin/class-wc-admin-post-types.php:1974 msgid "Featured Product" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1975 +#: includes/admin/class-wc-admin-post-types.php:1977 msgid "OK" msgstr "" -#: includes/admin/class-wc-admin-post-types.php:1976 +#: includes/admin/class-wc-admin-post-types.php:1978 #: includes/admin/meta-boxes/class-wc-meta-box-product-data.php:177 #: includes/admin/meta-boxes/views/html-order-items.php:234 #: includes/admin/meta-boxes/views/html-order-items.php:273 diff --git a/i18n/languages/woocommerce.pot b/i18n/languages/woocommerce.pot index 316c9d5a2bc..660c6fe9be3 100644 --- a/i18n/languages/woocommerce.pot +++ b/i18n/languages/woocommerce.pot @@ -2,16 +2,16 @@ # This file is distributed under the same license as the WooCommerce package. msgid "" msgstr "" -"Project-Id-Version: WooCommerce 2.2.0-bleeding Frontend\n" +"Project-Id-Version: WooCommerce 2.2.0-RC1 Frontend\n" "Report-Msgid-Bugs-To: https://github.com/woothemes/woocommerce/issues\n" -"POT-Creation-Date: 2014-09-04 14:14:15+00:00\n" +"POT-Creation-Date: 2014-09-08 15:44:12+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "PO-Revision-Date: 2014-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" -"X-Generator: grunt-wp-i18n 0.4.7\n" +"X-Generator: grunt-wp-i18n 0.4.8\n" #: i18n/countries.php:16 msgid "Afghanistan" @@ -4203,42 +4203,42 @@ msgstr "" msgid "Backordered" msgstr "" -#: includes/abstracts/abstract-wc-order.php:1614 +#: includes/abstracts/abstract-wc-order.php:1613 msgid " %svia %s" msgstr "" -#: includes/abstracts/abstract-wc-order.php:1619 -#: includes/abstracts/abstract-wc-product.php:883 -#: includes/abstracts/abstract-wc-product.php:889 +#: includes/abstracts/abstract-wc-order.php:1618 +#: includes/abstracts/abstract-wc-product.php:884 +#: includes/abstracts/abstract-wc-product.php:890 #: includes/class-wc-cart.php:1438 includes/class-wc-product-variation.php:289 msgid "Free!" msgstr "" -#: includes/abstracts/abstract-wc-order.php:1681 +#: includes/abstracts/abstract-wc-order.php:1680 msgid "Cart Subtotal:" msgstr "" -#: includes/abstracts/abstract-wc-order.php:1688 +#: includes/abstracts/abstract-wc-order.php:1687 msgid "Cart Discount:" msgstr "" -#: includes/abstracts/abstract-wc-order.php:1695 +#: includes/abstracts/abstract-wc-order.php:1694 msgid "Shipping:" msgstr "" -#: includes/abstracts/abstract-wc-order.php:1748 +#: includes/abstracts/abstract-wc-order.php:1747 msgid "Order Discount:" msgstr "" -#: includes/abstracts/abstract-wc-order.php:1755 +#: includes/abstracts/abstract-wc-order.php:1754 msgid "Payment Method:" msgstr "" -#: includes/abstracts/abstract-wc-order.php:1761 +#: includes/abstracts/abstract-wc-order.php:1760 msgid "Order Total:" msgstr "" -#: includes/abstracts/abstract-wc-order.php:1781 +#: includes/abstracts/abstract-wc-order.php:1780 #: includes/wc-cart-functions.php:250 msgid "(Includes %s)" msgstr "" @@ -4247,16 +4247,16 @@ msgstr "" msgid "WooCommerce" msgstr "" -#: includes/abstracts/abstract-wc-order.php:2073 +#: includes/abstracts/abstract-wc-order.php:2072 msgid "Order status changed from %s to %s." msgstr "" -#: includes/abstracts/abstract-wc-order.php:2336 +#: includes/abstracts/abstract-wc-order.php:2335 #: includes/class-wc-ajax.php:1161 includes/class-wc-ajax.php:1162 msgid "Item #%s stock reduced from %s to %s." msgstr "" -#: includes/abstracts/abstract-wc-order.php:2346 +#: includes/abstracts/abstract-wc-order.php:2345 msgid "Order item stock reduced successfully." msgstr "" @@ -4281,60 +4281,60 @@ msgstr "" msgid "CVC" msgstr "" -#: includes/abstracts/abstract-wc-product.php:468 +#: includes/abstracts/abstract-wc-product.php:469 #: includes/class-wc-product-simple.php:48 #: includes/class-wc-product-variation.php:197 msgid "Add to cart" msgstr "" -#: includes/abstracts/abstract-wc-product.php:477 +#: includes/abstracts/abstract-wc-product.php:478 msgid "Read more" msgstr "" -#: includes/abstracts/abstract-wc-product.php:558 -#: includes/abstracts/abstract-wc-product.php:569 -#: includes/abstracts/abstract-wc-product.php:591 +#: includes/abstracts/abstract-wc-product.php:559 +#: includes/abstracts/abstract-wc-product.php:570 +#: includes/abstracts/abstract-wc-product.php:592 #: includes/class-wc-ajax.php:624 includes/class-wc-product-variation.php:507 #: includes/class-wc-product-variation.php:517 #: includes/class-wc-product-variation.php:533 msgid "In stock" msgstr "" -#: includes/abstracts/abstract-wc-product.php:563 +#: includes/abstracts/abstract-wc-product.php:564 #: includes/class-wc-product-variation.php:511 msgid "Only %s left in stock" msgstr "" -#: includes/abstracts/abstract-wc-product.php:566 -#: includes/abstracts/abstract-wc-product.php:577 +#: includes/abstracts/abstract-wc-product.php:567 +#: includes/abstracts/abstract-wc-product.php:578 #: includes/class-wc-product-variation.php:514 #: includes/class-wc-product-variation.php:524 msgid "(can be backordered)" msgstr "" -#: includes/abstracts/abstract-wc-product.php:574 +#: includes/abstracts/abstract-wc-product.php:575 #: includes/class-wc-product-variation.php:521 msgid "%s in stock" msgstr "" -#: includes/abstracts/abstract-wc-product.php:586 +#: includes/abstracts/abstract-wc-product.php:587 #: includes/class-wc-product-variation.php:530 templates/cart/cart.php:72 msgid "Available on backorder" msgstr "" -#: includes/abstracts/abstract-wc-product.php:596 -#: includes/abstracts/abstract-wc-product.php:602 +#: includes/abstracts/abstract-wc-product.php:597 +#: includes/abstracts/abstract-wc-product.php:603 #: includes/class-wc-ajax.php:625 includes/class-wc-product-variation.php:536 #: includes/class-wc-product-variation.php:540 msgid "Out of stock" msgstr "" -#: includes/abstracts/abstract-wc-product.php:1011 +#: includes/abstracts/abstract-wc-product.php:1012 #: templates/single-product/rating.php:23 msgid "Rated %s out of 5" msgstr "" -#: includes/abstracts/abstract-wc-product.php:1013 +#: includes/abstracts/abstract-wc-product.php:1014 #: templates/single-product/rating.php:25 #: templates/single-product/review.php:27 msgid "out of 5" @@ -4627,7 +4627,7 @@ msgid "You do not have permission to create order notes" msgstr "" #: includes/api/class-wc-api-orders.php:1173 -#: includes/api/class-wc-api-orders.php:1448 +#: includes/api/class-wc-api-orders.php:1447 msgid "Order ID is invalid" msgstr "" @@ -4652,42 +4652,42 @@ msgstr "" msgid "This order note cannot be deleted" msgstr "" -#: includes/api/class-wc-api-orders.php:1373 -#: includes/api/class-wc-api-orders.php:1521 -#: includes/api/class-wc-api-orders.php:1577 +#: includes/api/class-wc-api-orders.php:1372 +#: includes/api/class-wc-api-orders.php:1520 +#: includes/api/class-wc-api-orders.php:1576 msgid "Invalid order refund ID" msgstr "" -#: includes/api/class-wc-api-orders.php:1380 -#: includes/api/class-wc-api-orders.php:1528 -#: includes/api/class-wc-api-orders.php:1584 +#: includes/api/class-wc-api-orders.php:1379 +#: includes/api/class-wc-api-orders.php:1527 +#: includes/api/class-wc-api-orders.php:1583 msgid "An order refund with the provided ID could not be found" msgstr "" -#: includes/api/class-wc-api-orders.php:1442 +#: includes/api/class-wc-api-orders.php:1441 msgid "You do not have permission to create order refunds" msgstr "" -#: includes/api/class-wc-api-orders.php:1455 +#: includes/api/class-wc-api-orders.php:1454 msgid "Refund amount is required" msgstr "" -#: includes/api/class-wc-api-orders.php:1457 +#: includes/api/class-wc-api-orders.php:1456 msgid "Refund amount must be positive" msgstr "" -#: includes/api/class-wc-api-orders.php:1467 +#: includes/api/class-wc-api-orders.php:1466 msgid "Cannot create order refund, please try again" msgstr "" -#: includes/api/class-wc-api-orders.php:1484 +#: includes/api/class-wc-api-orders.php:1483 msgid "" "An error occurred while attempting to create the refund using the payment " "gateway API" msgstr "" -#: includes/api/class-wc-api-orders.php:1533 -#: includes/api/class-wc-api-orders.php:1589 +#: includes/api/class-wc-api-orders.php:1532 +#: includes/api/class-wc-api-orders.php:1588 msgid "The order refund ID provided is not associated with the order" msgstr "" @@ -4723,8 +4723,8 @@ msgstr "" msgid "The SKU already exists on another product" msgstr "" -#: includes/api/class-wc-api-products.php:1085 includes/class-wc-emails.php:335 -#: includes/class-wc-emails.php:367 includes/class-wc-emails.php:411 +#: includes/api/class-wc-api-products.php:1085 includes/class-wc-emails.php:334 +#: includes/class-wc-emails.php:366 includes/class-wc-emails.php:410 msgid "Variation #%s of %s" msgstr "" @@ -5296,8 +5296,8 @@ msgstr "" #: includes/class-wc-download-handler.php:95 #: includes/class-wc-download-handler.php:100 #: includes/class-wc-download-handler.php:104 -#: includes/class-wc-download-handler.php:148 -#: includes/class-wc-download-handler.php:312 +#: includes/class-wc-download-handler.php:149 +#: includes/class-wc-download-handler.php:313 msgid "Go to homepage" msgstr "" @@ -5341,44 +5341,44 @@ msgstr "" msgid "Sorry, this download has expired" msgstr "" -#: includes/class-wc-download-handler.php:148 +#: includes/class-wc-download-handler.php:149 msgid "No file defined" msgstr "" -#: includes/class-wc-download-handler.php:312 +#: includes/class-wc-download-handler.php:313 msgid "File not found" msgstr "" -#: includes/class-wc-emails.php:288 +#: includes/class-wc-emails.php:287 msgid "Note" msgstr "" -#: includes/class-wc-emails.php:330 +#: includes/class-wc-emails.php:329 msgid "Product low in stock" msgstr "" -#: includes/class-wc-emails.php:337 includes/class-wc-emails.php:369 -#: includes/class-wc-emails.php:413 +#: includes/class-wc-emails.php:336 includes/class-wc-emails.php:368 +#: includes/class-wc-emails.php:412 msgid "Product #%s - %s" msgstr "" -#: includes/class-wc-emails.php:339 +#: includes/class-wc-emails.php:338 msgid "is low in stock." msgstr "" -#: includes/class-wc-emails.php:362 +#: includes/class-wc-emails.php:361 msgid "Product out of stock" msgstr "" -#: includes/class-wc-emails.php:371 +#: includes/class-wc-emails.php:370 msgid "is out of stock." msgstr "" -#: includes/class-wc-emails.php:406 +#: includes/class-wc-emails.php:405 msgid "Product Backorder" msgstr "" -#: includes/class-wc-emails.php:416 +#: includes/class-wc-emails.php:415 msgid "%s units of %s have been backordered in order %s." msgstr "" @@ -5956,7 +5956,7 @@ msgid "" "Changing status to draft." msgstr "" -#: includes/class-wc-product-variation.php:645 +#: includes/class-wc-product-variation.php:644 msgid "%s – %s%s" msgstr "" @@ -6715,7 +6715,7 @@ msgstr "" #: includes/gateways/simplify-commerce/class-wc-addons-gateway-simplify-commerce.php:47 #: includes/gateways/simplify-commerce/class-wc-addons-gateway-simplify-commerce.php:131 -#: includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php:276 +#: includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php:277 msgid "" "Please make sure your card details have been entered correctly and that " "your browser supports JavaScript." @@ -6723,7 +6723,7 @@ msgstr "" #: includes/gateways/simplify-commerce/class-wc-addons-gateway-simplify-commerce.php:50 #: includes/gateways/simplify-commerce/class-wc-addons-gateway-simplify-commerce.php:134 -#: includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php:279 +#: includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php:280 msgid "" "Developers: Please make sure that you're including jQuery and there are no " "JavaScript errors on the page." @@ -6755,17 +6755,17 @@ msgstr "" #: includes/gateways/simplify-commerce/class-wc-addons-gateway-simplify-commerce.php:257 #: includes/gateways/simplify-commerce/class-wc-addons-gateway-simplify-commerce.php:356 -#: includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php:304 +#: includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php:305 msgid "Simplify payment approved (ID: %s, Auth Code: %s)" msgstr "" #: includes/gateways/simplify-commerce/class-wc-addons-gateway-simplify-commerce.php:261 -#: includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php:315 +#: includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php:316 msgid "Simplify payment declined" msgstr "" #: includes/gateways/simplify-commerce/class-wc-addons-gateway-simplify-commerce.php:263 -#: includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php:317 +#: includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php:318 msgid "Payment was declined - please try another card." msgstr "" @@ -6895,11 +6895,11 @@ msgstr "" msgid "is invalid" msgstr "" -#: includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php:288 +#: includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php:289 msgid "%s - Order %s" msgstr "" -#: includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php:359 +#: includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php:360 msgid "Refund was declined." msgstr "" @@ -7574,19 +7574,19 @@ msgstr "" msgid "Egyptian Pound" msgstr "" -#: includes/wc-coupon-functions.php:22 +#: includes/wc-coupon-functions.php:22 tests/unit-tests/coupon-functions.php:17 msgid "Cart Discount" msgstr "" -#: includes/wc-coupon-functions.php:23 +#: includes/wc-coupon-functions.php:23 tests/unit-tests/coupon-functions.php:18 msgid "Cart % Discount" msgstr "" -#: includes/wc-coupon-functions.php:24 +#: includes/wc-coupon-functions.php:24 tests/unit-tests/coupon-functions.php:19 msgid "Product Discount" msgstr "" -#: includes/wc-coupon-functions.php:25 +#: includes/wc-coupon-functions.php:25 tests/unit-tests/coupon-functions.php:20 msgid "Product % Discount" msgstr "" @@ -7602,11 +7602,11 @@ msgid "" "the new WooCommerce post_status instead, read more..." msgstr "" -#: includes/wc-order-functions.php:476 +#: includes/wc-order-functions.php:475 msgid "Unpaid order cancelled - time limit reached." msgstr "" -#: includes/wc-order-functions.php:571 +#: includes/wc-order-functions.php:570 msgid "Refund – %s" msgstr "" @@ -7722,11 +7722,11 @@ msgstr "" msgid "Search" msgstr "" -#: includes/wc-term-functions.php:146 +#: includes/wc-term-functions.php:144 msgid "Select a category" msgstr "" -#: includes/wc-term-functions.php:149 +#: includes/wc-term-functions.php:147 msgid "Uncategorized" msgstr "" @@ -8929,12 +8929,12 @@ msgctxt "US state of Georgia" msgid "Georgia" msgstr "" -#: includes/abstracts/abstract-wc-order.php:872 +#: includes/abstracts/abstract-wc-order.php:871 msgctxt "hash before order number" msgid "#" msgstr "" -#: includes/abstracts/abstract-wc-product.php:905 +#: includes/abstracts/abstract-wc-product.php:906 msgctxt "min_price" msgid "From:" msgstr "" @@ -9112,17 +9112,17 @@ msgctxt "Tax status" msgid "None" msgstr "" -#: includes/wc-core-functions.php:73 includes/wc-order-functions.php:571 +#: includes/wc-core-functions.php:73 includes/wc-order-functions.php:570 msgctxt "Order date parsed by strftime" msgid "%b %d, %Y @ %I:%M %p" msgstr "" -#: includes/wc-page-functions.php:78 +#: includes/wc-page-functions.php:77 msgctxt "edit-address-slug" msgid "billing" msgstr "" -#: includes/wc-page-functions.php:79 +#: includes/wc-page-functions.php:78 msgctxt "edit-address-slug" msgid "shipping" msgstr "" diff --git a/includes/abstracts/abstract-wc-email.php b/includes/abstracts/abstract-wc-email.php index 9c01cb0c006..04d5f626648 100644 --- a/includes/abstracts/abstract-wc-email.php +++ b/includes/abstracts/abstract-wc-email.php @@ -233,7 +233,7 @@ abstract class WC_Email extends WC_Settings_API { /** * get_attachments function. * - * @return array + * @return string|array */ public function get_attachments() { return apply_filters( 'woocommerce_email_attachments', array(), $this->id, $this->object ); @@ -457,7 +457,7 @@ abstract class WC_Email extends WC_Settings_API { /** * Apply inline styles to dynamic content. * - * @param mixed $content + * @param string|null $content * @return string */ public function style_inline( $content ) { @@ -521,9 +521,9 @@ abstract class WC_Email extends WC_Settings_API { /** * Send the email. * - * @param mixed $to - * @param mixed $subject - * @param mixed $message + * @param string $to + * @param string $subject + * @param string $message * @param string $headers * @param string $attachments * @return bool @@ -589,7 +589,7 @@ abstract class WC_Email extends WC_Settings_API { * - Saves the options to the DB * * @since 1.0.0 - * @return bool + * @return boolean|null */ public function process_admin_options() { diff --git a/includes/abstracts/abstract-wc-order.php b/includes/abstracts/abstract-wc-order.php index 987d2c1769c..89fc2030941 100644 --- a/includes/abstracts/abstract-wc-order.php +++ b/includes/abstracts/abstract-wc-order.php @@ -25,7 +25,6 @@ abstract class WC_Abstract_Order { * should be used. It is possible, but the aforementioned are preferred and are the only * methods that will be maintained going forward. * - * @param string $id The order id. Default ''. */ public function __construct( $order = '' ) { @@ -78,6 +77,7 @@ abstract class WC_Abstract_Order { * Set the payment method for the order * * @param WC_Payment_Gateway + * @param WC_Payment_Gateway $payment_method */ public function set_payment_method( $payment_method ) { @@ -227,7 +227,7 @@ abstract class WC_Abstract_Order { * Add coupon code to the order * * @param string $code - * @param float|int $discount_amount + * @param integer $discount_amount * @return int|bool Item ID or false */ public function add_coupon( $code, $discount_amount = 0 ) { @@ -810,7 +810,6 @@ abstract class WC_Abstract_Order { /** * Checks the order status against a passed in status. * - * @param mixed $type Array or string of types * @return bool */ public function has_status( $status ) { @@ -2070,7 +2069,8 @@ abstract class WC_Abstract_Order { // Update the order wp_update_post( array( 'ID' => $this->id, 'post_status' => 'wc-' . $new_status ) ); $this->post_status = 'wc-' . $new_status; - $this->add_order_note( trim( $note . ' ' . sprintf( __( 'Order status changed from %s to %s.', 'woocommerce' ), $old_status, $new_status ) ) ); + + $this->add_order_note( trim( $note . ' ' . sprintf( __( 'Order status changed from %s to %s.', 'woocommerce' ), strtolower( wc_get_order_status_label( $old_status ) ), strtolower( wc_get_order_status_label( $new_status ) ) ) ) ); // Status was changed do_action( 'woocommerce_order_status_' . $new_status, $this->id ); @@ -2350,7 +2350,7 @@ abstract class WC_Abstract_Order { /** * send_stock_notifications function. * - * @param object $product + * @param WC_Product $product * @param int $new_stock * @param int $qty_ordered */ @@ -2432,7 +2432,7 @@ abstract class WC_Abstract_Order { /** * Checks if an order needs display the shipping address, based on shipping method * - * @return bool + * @return boolean|null */ public function needs_shipping_address() { diff --git a/includes/abstracts/abstract-wc-payment-gateway.php b/includes/abstracts/abstract-wc-payment-gateway.php index e004c69fddf..cf5d1c252cf 100644 --- a/includes/abstracts/abstract-wc-payment-gateway.php +++ b/includes/abstracts/abstract-wc-payment-gateway.php @@ -211,7 +211,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API { * @param int $order_id * @param float $amount * @param string $reason - * @return bool|wp_error True or false based on success, or a WP_Error object + * @return boolean True or false based on success, or a WP_Error object */ public function process_refund( $order_id, $amount = null, $reason = '' ) { return false; @@ -245,7 +245,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API { * Gateways should override this to declare support (or lack of support) for a feature. * For backward compatibility, gateways support 'products' by default, but nothing else. * - * @param $feature string The name of a feature to test support for. + * @param string $feature string The name of a feature to test support for. * @return bool True if the gateway supports the feature, false otherwise. * @since 1.5.7 */ diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php index 72dd6693316..b6a3f06c3aa 100644 --- a/includes/abstracts/abstract-wc-product.php +++ b/includes/abstracts/abstract-wc-product.php @@ -53,7 +53,7 @@ class WC_Product { /** * __get function. * - * @param mixed $key + * @param string $key * @return mixed */ public function __get( $key ) { @@ -225,6 +225,7 @@ class WC_Product { /** * set_stock_status function. * + * @param string $status * @return void */ public function set_stock_status( $status ) { @@ -248,7 +249,7 @@ class WC_Product { * * Backwards compat with downloadable/virtual. * - * @param mixed $type Array or string of types + * @param string $type Array or string of types * @return bool */ public function is_type( $type ) { @@ -908,7 +909,7 @@ class WC_Product { /** * Functions for getting parts of a price, in html, used by get_price_html. * - * @param mixed $from String or float to wrap with 'from' text + * @param string $from String or float to wrap with 'from' text * @param mixed $to String or float to wrap with 'to' text * @return string */ @@ -1227,7 +1228,7 @@ class WC_Product { /** * Returns whether or not the product has any attributes set. * - * @return mixed + * @return boolean */ public function has_attributes() { @@ -1354,7 +1355,6 @@ class WC_Product { /** * Get product name with SKU or ID. Used within admin. * - * @param mixed $product * @return string Formatted product name */ public function get_formatted_name() { diff --git a/includes/abstracts/abstract-wc-widget.php b/includes/abstracts/abstract-wc-widget.php index e9087f54a06..50f15b82cdf 100644 --- a/includes/abstracts/abstract-wc-widget.php +++ b/includes/abstracts/abstract-wc-widget.php @@ -54,6 +54,7 @@ abstract class WC_Widget extends WP_Widget { /** * Cache the widget + * @param string $content */ public function cache_widget( $args, $content ) { $cache[ $args['widget_id'] ] = $content; diff --git a/includes/admin/class-wc-admin-help.php b/includes/admin/class-wc-admin-help.php index 1ea458fe7f0..10606976c76 100644 --- a/includes/admin/class-wc-admin-help.php +++ b/includes/admin/class-wc-admin-help.php @@ -49,11 +49,11 @@ class WC_Admin_Help { 'title' => __( 'Support', 'woocommerce' ), 'content' => - '

' . sprintf( __( 'After reading the documentation, for further assistance you can use the community forum, or if you have access as a WooThemes customer, our support desk.', 'woocommerce' ), 'http://docs.woothemes.com/documentation/plugins/woocommerce/', 'http://wordpress.org/support/plugin/woocommerce', 'http://support.woothemes.com' ) . '

' . + '

' . sprintf( __( 'After %sreading the documentation%s, for further assistance you can use our %scommunity forum%s if you get stuck. For help with premium add-ons from WooThemes, or if you are a WooThemes customer, you can %suse our helpdesk%s.', 'woocommerce' ), '', '', '', '', '', '' ) . '

' . '

' . __( 'Before asking for help we recommend checking the status page to identify any problems with your configuration.', 'woocommerce' ) . '

' . - '

' . __( 'System Status', 'woocommerce' ) . ' ' . __( 'Community Support', 'woocommerce' ) . ' ' . __( 'Customer Support', 'woocommerce' ) . '

' + '

' . __( 'System Status', 'woocommerce' ) . ' ' . __( 'WooThemes Community Support', 'woocommerce' ) . ' ' . __( 'WooThemes Customer Support', 'woocommerce' ) . '

' ) ); diff --git a/includes/admin/class-wc-admin-post-types.php b/includes/admin/class-wc-admin-post-types.php index 35fb427cf60..4b704d758e0 100644 --- a/includes/admin/class-wc-admin-post-types.php +++ b/includes/admin/class-wc-admin-post-types.php @@ -803,6 +803,7 @@ class WC_Admin_Post_Types { /** * Quick edit + * @param integer $post_id */ private function quick_edit_save( $post_id, $product ) { global $wpdb; @@ -924,6 +925,7 @@ class WC_Admin_Post_Types { /** * Bulk edit + * @param integer $post_id */ public function bulk_edit_save( $post_id, $product ) { diff --git a/includes/admin/class-wc-admin-settings.php b/includes/admin/class-wc-admin-settings.php index 9f95e85f2db..266519891b1 100644 --- a/includes/admin/class-wc-admin-settings.php +++ b/includes/admin/class-wc-admin-settings.php @@ -149,7 +149,7 @@ class WC_Admin_Settings { /** * Get a setting from the settings API. * - * @param mixed $option + * @param mixed $option_name * @return string */ public static function get_option( $option_name, $default = '' ) { diff --git a/includes/admin/class-wc-admin-status.php b/includes/admin/class-wc-admin-status.php index 7256902d450..b8c486418b0 100644 --- a/includes/admin/class-wc-admin-status.php +++ b/includes/admin/class-wc-admin-status.php @@ -240,7 +240,7 @@ class WC_Admin_Status { * * @since 2.1.1 * @param string $file Path to the file - * @param array $all_headers List of headers, in the format array('HeaderKey' => 'Header Name') + * @return string */ public static function get_file_version( $file ) { // We don't need to write to the file, so just open for reading. diff --git a/includes/admin/settings/class-wc-settings-general.php b/includes/admin/settings/class-wc-settings-general.php index 6b8522eef1b..46b45c5e56f 100644 --- a/includes/admin/settings/class-wc-settings-general.php +++ b/includes/admin/settings/class-wc-settings-general.php @@ -266,7 +266,7 @@ class WC_Settings_General extends WC_Settings_Page { * Output a colour picker input box. * * @param mixed $name - * @param mixed $id + * @param string $id * @param mixed $value * @param string $desc (default: '') */ diff --git a/includes/admin/wc-admin-functions.php b/includes/admin/wc-admin-functions.php index 76c06848932..428e76a8f2a 100644 --- a/includes/admin/wc-admin-functions.php +++ b/includes/admin/wc-admin-functions.php @@ -46,7 +46,7 @@ function wc_get_screen_ids() { * * @access public * @param mixed $slug Slug for the new page - * @param mixed $option Option name to store the page's ID + * @param string $option Option name to store the page's ID * @param string $page_title (default: '') Title for the new page * @param string $page_content (default: '') Content for the new page * @param int $post_parent (default: 0) Parent for the new page @@ -130,7 +130,7 @@ function woocommerce_update_options( $options ) { /** * Get a setting from the settings API. * - * @param mixed $option + * @param mixed $option_name * @return string */ function woocommerce_settings_get_option( $option_name, $default = '' ) { diff --git a/includes/api/class-wc-api-customers.php b/includes/api/class-wc-api-customers.php index 58b1b1e2386..86839cdba6b 100644 --- a/includes/api/class-wc-api-customers.php +++ b/includes/api/class-wc-api-customers.php @@ -674,7 +674,7 @@ class WC_API_Customers extends WC_API_Resource { * * @since 2.1 * @see WC_API_Resource::validate_request() - * @param string|int $id the customer ID + * @param integer $id the customer ID * @param string $type the request type, unused because this method overrides the parent class * @param string $context the context of the request, either `read`, `edit` or `delete` * @return int|WP_Error valid user ID or WP_Error if any of the checks fails diff --git a/includes/api/class-wc-api-orders.php b/includes/api/class-wc-api-orders.php index b40f70c2d2c..e977640b367 100644 --- a/includes/api/class-wc-api-orders.php +++ b/includes/api/class-wc-api-orders.php @@ -1354,7 +1354,6 @@ class WC_API_Orders extends WC_API_Resource { * * @since 2.2 * @param string $order_id order ID - * @param int $refund order refund ID * @param string|null $fields fields to limit response to * @return array */ diff --git a/includes/api/class-wc-api-products.php b/includes/api/class-wc-api-products.php index 8477ddf1f63..5b5c7fbf2f5 100644 --- a/includes/api/class-wc-api-products.php +++ b/includes/api/class-wc-api-products.php @@ -495,7 +495,7 @@ class WC_API_Products extends WC_API_Resource { * * @since 2.1 * @param WC_Product $product - * @return array + * @return WC_Product */ private function get_product_data( $product ) { @@ -1440,7 +1440,7 @@ class WC_API_Products extends WC_API_Resource { * * @since 2.2 * @param string $label - * @return stdClass + * @return string|null */ private function get_attribute_taxonomy_by_label( $label ) { $taxonomy = null; @@ -1653,7 +1653,7 @@ class WC_API_Products extends WC_API_Resource { * Get product image as attachment * * @since 2.2 - * @param array $upload + * @param integer $upload * @param int $id * @return int */ diff --git a/includes/api/class-wc-api-server.php b/includes/api/class-wc-api-server.php index a6ff98979fe..c300de73d61 100644 --- a/includes/api/class-wc-api-server.php +++ b/includes/api/class-wc-api-server.php @@ -446,7 +446,7 @@ class WC_API_Server { 'ssl_enabled' => ( 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ), 'permalinks_enabled' => ( '' !== get_option( 'permalink_structure' ) ), 'links' => array( - 'help' => 'http://woothemes.github.io/woocommerce/rest-api/', + 'help' => 'http://docs.woocommercev2.apiary.io/', ), ), ) ); diff --git a/includes/class-wc-ajax.php b/includes/class-wc-ajax.php index 1de57e0a42d..7ccdcd0601b 100644 --- a/includes/class-wc-ajax.php +++ b/includes/class-wc-ajax.php @@ -1809,7 +1809,7 @@ class WC_AJAX { check_ajax_referer( 'order-item', 'security' ); $order_id = absint( $_POST['order_id'] ); - $refund_amount = sanitize_text_field( $_POST['refund_amount'] ); + $refund_amount = wc_format_decimal( sanitize_text_field( $_POST['refund_amount'] ) ); $refund_reason = sanitize_text_field( $_POST['refund_reason'] ); $line_item_qtys = json_decode( sanitize_text_field( stripslashes( $_POST['line_item_qtys'] ) ), true ); $line_item_totals = json_decode( sanitize_text_field( stripslashes( $_POST['line_item_totals'] ) ), true ); @@ -1850,10 +1850,10 @@ class WC_AJAX { } } foreach ( $line_item_totals as $item_id => $total ) { - $line_items[ $item_id ]['refund_total'] = $total; + $line_items[ $item_id ]['refund_total'] = wc_format_decimal( $total ); } foreach ( $line_item_tax_totals as $item_id => $tax_totals ) { - $line_items[ $item_id ]['refund_tax'] = $tax_totals; + $line_items[ $item_id ]['refund_tax'] = array_map( 'wc_format_decimal', $tax_totals ); } // Create the refund object diff --git a/includes/class-wc-api.php b/includes/class-wc-api.php index 2c4176fa703..ab8d65869f0 100644 --- a/includes/class-wc-api.php +++ b/includes/class-wc-api.php @@ -53,7 +53,7 @@ class WC_API { * @access public * @since 2.0 * @param $vars - * @return array + * @return string[] */ public function add_query_vars( $vars ) { $vars[] = 'wc-api'; @@ -157,7 +157,7 @@ class WC_API { * Register available API resources * * @since 2.1 - * @param object $server the REST server + * @param WC_API_Server $server the REST server */ public function register_resources( $server ) { diff --git a/includes/class-wc-cart.php b/includes/class-wc-cart.php index 2fa10e76cc0..912cda9d9d8 100644 --- a/includes/class-wc-cart.php +++ b/includes/class-wc-cart.php @@ -775,7 +775,7 @@ class WC_Cart { * Add a product to the cart. * * @param string $product_id contains the id of the product to add to the cart - * @param string $quantity contains the quantity of the item to add + * @param integer $quantity contains the quantity of the item to add * @param int $variation_id * @param array $variation attribute values * @param array $cart_item_data extra cart item data we want to pass into the item @@ -1783,7 +1783,7 @@ class WC_Cart { * * @access public * @param mixed $values - * @param mixed $price + * @param double $price */ public function apply_product_discounts_after_tax( $values, $price ) { if ( ! empty( $this->applied_coupons ) ) { @@ -1807,7 +1807,7 @@ class WC_Cart { * * @access private * @param mixed $code - * @param mixed $amount + * @param double $amount */ private function increase_coupon_discount_amount( $code, $amount ) { if ( empty( $this->coupon_discount_amounts[ $code ] ) ) @@ -1821,7 +1821,7 @@ class WC_Cart { * * @access private * @param mixed $code - * @param mixed $amount + * @param integer $count */ private function increase_coupon_applied_count( $code, $count = 1 ) { if ( empty( $this->coupon_applied_count[ $code ] ) ) diff --git a/includes/class-wc-countries.php b/includes/class-wc-countries.php index 4460ef2852a..64f3f43ecb2 100644 --- a/includes/class-wc-countries.php +++ b/includes/class-wc-countries.php @@ -252,7 +252,7 @@ class WC_Countries { * Gets an array of countries in the EU. * * @access public - * @return array + * @return string[] */ public function get_european_union_countries() { return array( 'AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HU', 'HR', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK' ); diff --git a/includes/class-wc-coupon.php b/includes/class-wc-coupon.php index 7ee625b4c59..346738265d8 100644 --- a/includes/class-wc-coupon.php +++ b/includes/class-wc-coupon.php @@ -278,7 +278,7 @@ class WC_Coupon { * Check if a coupon is valid. Return a reason code if invalid. Reason codes: * * @access public - * @return bool|WP_Error validity or a WP_Error if not valid + * @return boolean validity or a WP_Error if not valid */ public function is_valid() { @@ -599,7 +599,7 @@ class WC_Coupon { * Map one of the WC_Coupon message codes to a message string * * @access public - * @param mixed $msg_code + * @param integer $msg_code * @return string| Message/error string */ public function get_coupon_message( $msg_code ) { diff --git a/includes/class-wc-customer.php b/includes/class-wc-customer.php index 6b7e15f13ad..0ca214171b9 100644 --- a/includes/class-wc-customer.php +++ b/includes/class-wc-customer.php @@ -331,7 +331,7 @@ class WC_Customer { $tax_based_on = get_option( 'woocommerce_tax_based_on' ); // Check shipping method at this point to see if we need special handling - if ( apply_filters( 'woocommerce_apply_base_tax_for_local_pickup', true ) == true && sizeof( array_intersect( WC()->session->get( 'chosen_shipping_methods', array( get_option( 'woocommerce_default_shipping_method' ) ) ), apply_filters( 'woocommerce_local_pickup_methods', array( 'local_pickup' ) ) ) ) > 0 ) { + if ( apply_filters( 'woocommerce_apply_base_tax_for_local_pickup', true ) == true && WC()->cart->needs_shipping() && sizeof( array_intersect( WC()->session->get( 'chosen_shipping_methods', array( get_option( 'woocommerce_default_shipping_method' ) ) ), apply_filters( 'woocommerce_local_pickup_methods', array( 'local_pickup' ) ) ) ) > 0 ) { $tax_based_on = 'base'; } @@ -372,8 +372,8 @@ class WC_Customer { * Sets session data for the location. * * @access public - * @param mixed $country - * @param mixed $state + * @param string $country + * @param string $state * @param string $postcode (default: '') * @param string $city (default: '') */ @@ -448,7 +448,7 @@ class WC_Customer { * Sets session data for the location. * * @access public - * @param mixed $country + * @param string $country * @param string $state (default: '') * @param string $postcode (default: '') * @param string $city (default: '') @@ -534,7 +534,7 @@ class WC_Customer { * calculated_shipping function. * * @access public - * @param mixed $calculated + * @param boolean $calculated */ public function calculated_shipping( $calculated = true ) { $this->calculated_shipping = $calculated; diff --git a/includes/class-wc-download-handler.php b/includes/class-wc-download-handler.php index 425cf92f90b..65806fedffe 100644 --- a/includes/class-wc-download-handler.php +++ b/includes/class-wc-download-handler.php @@ -91,7 +91,7 @@ class WC_Download_Handler { if ( $order_id ) { $order = wc_get_order( $order_id ); - if ( ! $order->is_download_permitted() || $order->post_status != 'wc-completed' ) { + if ( ! $order->is_download_permitted() ) { wp_die( __( 'Invalid order.', 'woocommerce' ) . ' ' . __( 'Go to homepage', 'woocommerce' ) . '', '', array( 'response' => 404 ) ); } } @@ -138,6 +138,7 @@ class WC_Download_Handler { /** * Download a file - hook into init function. + * @param integer $product_id */ public static function download( $file_path, $product_id ) { global $is_IE; diff --git a/includes/class-wc-emails.php b/includes/class-wc-emails.php index 4ecb8baf396..835d8b515b4 100644 --- a/includes/class-wc-emails.php +++ b/includes/class-wc-emails.php @@ -190,7 +190,7 @@ class WC_Emails { * * @access public * @param mixed $email_heading - * @param mixed $message + * @param string $message * @return string */ function wrap_message( $email_heading, $message, $plain_text = false ) { @@ -244,7 +244,6 @@ class WC_Emails { * Prepare and send the customer invoice email on demand. * * @access public - * @param mixed $pay_for_order * @return void */ function customer_invoice( $order ) { diff --git a/includes/class-wc-https.php b/includes/class-wc-https.php index 4f490c09535..dd4ec6f49c9 100644 --- a/includes/class-wc-https.php +++ b/includes/class-wc-https.php @@ -69,8 +69,6 @@ class WC_HTTPS { /** * Force a post link to be SSL if needed * - * @param string $post_link - * @param object $post * @return string */ public static function force_https_page_link( $link, $page_id ) { diff --git a/includes/class-wc-language-pack-upgrader.php b/includes/class-wc-language-pack-upgrader.php index d5ecc0d72ab..319283a4843 100644 --- a/includes/class-wc-language-pack-upgrader.php +++ b/includes/class-wc-language-pack-upgrader.php @@ -28,7 +28,7 @@ class WC_Language_Pack_Upgrader { */ public function __construct() { add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_for_update' ) ); - add_filter( 'upgrader_post_install', array( $this, 'version_update' ), 999, 2 ); + add_filter( 'upgrader_pre_download', array( $this, 'version_update' ), 10, 2 ); add_action( 'woocommerce_language_pack_updater_check', array( $this, 'has_available_update' ) ); } @@ -117,28 +117,26 @@ class WC_Language_Pack_Upgrader { /** * Update the language version in database * - * @param bool $response Install response (true = success, false = fail) - * @param array $hook_extra Extra arguments passed to hooked filters + * This updates the database while the download the translation package and ensures that not generate download loop + * If the installation fails you can redo it in: WooCommerce > Sistem Status > Tools > Force Translation Upgrade + * + * @param bool $reply Whether to bail without returning the package (default: false) + * @param string $package Package URL * * @return bool */ - public function version_update( $response, $hook_extra ) { - if ( $response ) { - if ( - ( isset( $hook_extra['language_update_type'] ) && 'plugin' == $hook_extra['language_update_type'] ) - && ( isset( $hook_extra['language_update']->slug ) && 'woocommerce' == $hook_extra['language_update']->slug ) - ) { - // Update the language pack version - update_option( 'woocommerce_language_pack_version', array( WC_VERSION , get_locale() ) ); + public function version_update( $reply, $package ) { + if ( $package === $this->get_language_package_uri() ) { + // Update the language pack version + update_option( 'woocommerce_language_pack_version', array( WC_VERSION , get_locale() ) ); - // Remove the translation upgrade notice - $notices = get_option( 'woocommerce_admin_notices', array() ); - $notices = array_diff( $notices, array( 'translation_upgrade' ) ); - update_option( 'woocommerce_admin_notices', $notices ); - } + // Remove the translation upgrade notice + $notices = get_option( 'woocommerce_admin_notices', array() ); + $notices = array_diff( $notices, array( 'translation_upgrade' ) ); + update_option( 'woocommerce_admin_notices', $notices ); } - return $response; + return $reply; } } diff --git a/includes/class-wc-order.php b/includes/class-wc-order.php index c2896c579a2..a5bc2922fa8 100644 --- a/includes/class-wc-order.php +++ b/includes/class-wc-order.php @@ -75,7 +75,7 @@ class WC_Order extends WC_Abstract_Order { * * @param int $item_id ID of the item we're checking * @param string $item_type type of the item we're checking, if not a line_item - * @return float|int + * @return integer */ public function get_qty_refunded_for_item( $item_id, $item_type = 'line_item' ) { $qty = 0; @@ -94,7 +94,7 @@ class WC_Order extends WC_Abstract_Order { * * @param int $item_id ID of the item we're checking * @param string $item_type type of the item we're checking, if not a line_item - * @return float|int + * @return integer */ public function get_total_refunded_for_item( $item_id, $item_type = 'line_item' ) { $total = 0; @@ -121,7 +121,7 @@ class WC_Order extends WC_Abstract_Order { * @param int $item_id ID of the item we're checking * @param int $tax_id ID of the tax we're checking * @param string $item_type type of the item we're checking, if not a line_item - * @return float|int + * @return integer */ public function get_tax_refunded_for_item( $item_id, $tax_id, $item_type = 'line_item' ) { $total = 0; diff --git a/includes/class-wc-product-variation.php b/includes/class-wc-product-variation.php index ae9fab63f2f..9a7d52cb821 100644 --- a/includes/class-wc-product-variation.php +++ b/includes/class-wc-product-variation.php @@ -66,7 +66,7 @@ class WC_Product_Variation extends WC_Product { * Loads required variation data. * * @access public - * @param int $variation_id ID of the variation to load + * @param int $variation ID of the variation to load * @param array $args Array of the arguments containing parent product data */ public function __construct( $variation, $args = array() ) { @@ -629,7 +629,6 @@ class WC_Product_Variation extends WC_Product { * Get product name with extra details such as SKU, price and attributes. Used within admin. * * @access public - * @param mixed $product * @return string Formatted product name, including attributes and price */ public function get_formatted_name() { diff --git a/includes/class-wc-query.php b/includes/class-wc-query.php index 716ef76fa61..f762bb9c224 100644 --- a/includes/class-wc-query.php +++ b/includes/class-wc-query.php @@ -240,8 +240,6 @@ class WC_Query { add_filter( 'wp', array( $this, 'remove_posts_where' ) ); } - add_filter( 'posts_where', array( $this, 'exclude_protected_products' ) ); - // We're on a shop page so queue the woocommerce_get_products_in_view function add_action( 'wp', array( $this, 'get_products_in_view' ), 2); @@ -270,18 +268,6 @@ class WC_Query { return $where; } - /** - * Prevent password protected products appearing in the loops - * - * @param string $where - * @return string - */ - public function exclude_protected_products( $where ) { - global $wpdb; - $where .= " AND {$wpdb->posts}.post_password = ''"; - return $where; - } - /** * wpseo_metadesc function. * Hooked into wpseo_ hook already, so no need for function_exist diff --git a/includes/class-wc-webhook.php b/includes/class-wc-webhook.php index cc79037f0dc..a36db5b7af7 100644 --- a/includes/class-wc-webhook.php +++ b/includes/class-wc-webhook.php @@ -342,7 +342,7 @@ class WC_Webhook { // save request data add_comment_meta( $delivery_id, '_request_method', $request['method'] ); - add_comment_meta( $delivery_id, '_request_headers', array_merge( (array) $request['user-agent'], $request['headers'] ) ); + add_comment_meta( $delivery_id, '_request_headers', array_merge( array( 'User-Agent' => $request['user-agent'] ), $request['headers'] ) ); add_comment_meta( $delivery_id, '_request_body', $request['body'] ); // parse response diff --git a/includes/gateways/mijireh/includes/Order.php b/includes/gateways/mijireh/includes/Order.php index b2bab2dae16..2e9d0dfc040 100644 --- a/includes/gateways/mijireh/includes/Order.php +++ b/includes/gateways/mijireh/includes/Order.php @@ -188,6 +188,10 @@ class Mijireh_Order extends Mijireh_Model { } } + /** + * @param string $key + * @param integer $value + */ public function add_meta_data($key, $value) { if(!is_array($this->_data['meta_data'])) { $this->_data['meta_data'] = array(); @@ -199,6 +203,7 @@ class Mijireh_Order extends Mijireh_Model { * Return the value associated with the given key in the order's meta data. * * If the key does not exist, return false. + * @param string $key */ public function get_meta_value($key) { $value = false; diff --git a/includes/gateways/mijireh/includes/Rest.php b/includes/gateways/mijireh/includes/Rest.php index aef02d575ca..3666f2a6512 100644 --- a/includes/gateways/mijireh/includes/Rest.php +++ b/includes/gateways/mijireh/includes/Rest.php @@ -50,6 +50,10 @@ class Mijireh_Rest { } // $auth can be 'basic' or 'digest' + + /** + * @param string $pass + */ public function setupAuth($user, $pass, $auth = 'basic') { $this->curl_opts[CURLOPT_HTTPAUTH] = constant('CURLAUTH_'.strtoupper($auth)); $this->curl_opts[CURLOPT_USERPWD] = $user . ":" . $pass; @@ -64,6 +68,10 @@ class Mijireh_Rest { return $body; } + /** + * @param string $data + * @param string $url + */ public function post($url, $data, $headers=array()) { $data = (is_array($data)) ? http_build_query($data) : $data; @@ -81,6 +89,9 @@ class Mijireh_Rest { return $body; } + /** + * @param string $data + */ public function put($url, $data, $headers=array()) { $data = (is_array($data)) ? http_build_query($data) : $data; @@ -125,6 +136,9 @@ class Mijireh_Rest { return $body; } + /** + * @return string|null + */ protected function processError($body) { // Override this in classes that extend Mijireh_Rest. // The body of every erroneous (non-2xx/3xx) GET/POST/PUT/DELETE @@ -159,6 +173,9 @@ class Mijireh_Rest { return $curl; } + /** + * @param resource $curl + */ private function doRequest($curl) { $body = curl_exec($curl); diff --git a/includes/gateways/mijireh/includes/RestJSON.php b/includes/gateways/mijireh/includes/RestJSON.php index 79cab8ea5d0..4f9e18de35e 100644 --- a/includes/gateways/mijireh/includes/RestJSON.php +++ b/includes/gateways/mijireh/includes/RestJSON.php @@ -4,6 +4,9 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly class Mijireh_RestJSON extends Mijireh_Rest { + /** + * @param string $url + */ public function post($url, $data, $headers=array()) { return parent::post($url, json_encode($data), $headers); } diff --git a/includes/gateways/simplify-commerce/class-wc-addons-gateway-simplify-commerce.php b/includes/gateways/simplify-commerce/class-wc-addons-gateway-simplify-commerce.php index 59be76bd7aa..9f3e3496dd6 100644 --- a/includes/gateways/simplify-commerce/class-wc-addons-gateway-simplify-commerce.php +++ b/includes/gateways/simplify-commerce/class-wc-addons-gateway-simplify-commerce.php @@ -216,7 +216,7 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce { * process_subscription_payment function. * * @param WC_order $order - * @param float $amount (default: 0) + * @param integer $amount (default: 0) * @return bool|WP_Error */ public function process_subscription_payment( $order = '', $amount = 0 ) { @@ -318,7 +318,7 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce { * Process a pre-order payment when the pre-order is released * * @param WC_Order $order - * @return void + * @return wp_error|null */ public function process_pre_order_release_payment( $order ) { diff --git a/includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php b/includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php index 438c110dccf..5784938133e 100644 --- a/includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php +++ b/includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php @@ -248,7 +248,7 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway { * Outputs scripts used for simplify payment */ public function payment_scripts() { - if ( ! is_checkout() ) { + if ( ! is_checkout() || ! $this->is_available() ) { return; } @@ -265,6 +265,7 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway { /** * Process the payment + * @param integer $order_id */ public function process_payment( $order_id ) { $order = new WC_Order( $order_id ); diff --git a/includes/gateways/simplify-commerce/includes/Simplify/AccessToken.php b/includes/gateways/simplify-commerce/includes/Simplify/AccessToken.php index 60677d9ef56..34096331d62 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/AccessToken.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/AccessToken.php @@ -104,6 +104,11 @@ class Simplify_AccessToken extends Simplify_Object { return $this; } + /** + * @param string $props + * @param string $context + * @param Simplify_Authentication $authentication + */ private static function sendRequest($props, $context, $authentication){ $url = Simplify_Constants::OAUTH_BASE_URL.'/'.$context; diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Chargeback.php b/includes/gateways/simplify-commerce/includes/Simplify/Chargeback.php index 9421704d0d0..c12f3b1b8b4 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Chargeback.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Chargeback.php @@ -37,7 +37,7 @@ class Simplify_Chargeback extends Simplify_Object { *
offset
Used in paging of the list. This is the start offset of the page. [default: 0]
*
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id amount description dateCreated.
* @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Chargeback objects and the total + * @return Simplify_ResourceList a ResourceList object that holds the list of Chargeback objects and the total * number of Chargeback objects available for the given criteria. * @see ResourceList */ diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Coupon.php b/includes/gateways/simplify-commerce/includes/Simplify/Coupon.php index 5b341c32acc..178b8a9c2a1 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Coupon.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Coupon.php @@ -81,7 +81,7 @@ class Simplify_Coupon extends Simplify_Object { *
offset
Used in paging of the list. This is the start offset of the page. [default: 0]
*
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated maxRedemptions timesRedeemed id startDate endDate percentOff couponCode durationInMonths amountOff.
* @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Coupon objects and the total + * @return Simplify_ResourceList a ResourceList object that holds the list of Coupon objects and the total * number of Coupon objects available for the given criteria. * @see ResourceList */ diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Customer.php b/includes/gateways/simplify-commerce/includes/Simplify/Customer.php index 83914f2136c..69bafbdd663 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Customer.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Customer.php @@ -97,7 +97,7 @@ class Simplify_Customer extends Simplify_Object { *
offset
Used in paging of the list. This is the start offset of the page. [default: 0]
*
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated id name email reference.
* @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Customer objects and the total + * @return Simplify_ResourceList a ResourceList object that holds the list of Customer objects and the total * number of Customer objects available for the given criteria. * @see ResourceList */ diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Deposit.php b/includes/gateways/simplify-commerce/includes/Simplify/Deposit.php index b8b53b77b8d..9572b1aad93 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Deposit.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Deposit.php @@ -37,7 +37,7 @@ class Simplify_Deposit extends Simplify_Object { *
offset
Used in paging of the list. This is the start offset of the page. [default: 0]
*
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: amount dateCreated depositDate.
* @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Deposit objects and the total + * @return Simplify_ResourceList a ResourceList object that holds the list of Deposit objects and the total * number of Deposit objects available for the given criteria. * @see ResourceList */ diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Exceptions.php b/includes/gateways/simplify-commerce/includes/Simplify/Exceptions.php index 8c760edd83a..12f5f7d794e 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Exceptions.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Exceptions.php @@ -122,6 +122,7 @@ class Simplify_ApiConnectionException extends Simplify_ApiException { /** * @ignore + * @param string $message */ function __construct($message, $status = null, $errorData = null) { parent::__construct($message, $status, $errorData); @@ -135,6 +136,7 @@ class Simplify_AuthenticationException extends Simplify_ApiException { /** * @ignore + * @param string $message */ function __construct($message, $status = null, $errorData = null) { parent::__construct($message, $status, $errorData); @@ -150,6 +152,7 @@ class Simplify_BadRequestException extends Simplify_ApiException { /** * @ignore + * @param string $message */ function __construct($message, $status = null, $errorData = null) { parent::__construct($message, $status, $errorData); @@ -258,6 +261,7 @@ class Simplify_ObjectNotFoundException extends Simplify_ApiException { /** * @ignore + * @param string $message */ function __construct($message, $status = null, $errorData = null) { parent::__construct($message, $status, $errorData); @@ -271,6 +275,7 @@ class Simplify_NotAllowedException extends Simplify_ApiException { /** * @ignore + * @param string $message */ function __construct($message, $status = null, $errorData = null) { parent::__construct($message, $status, $errorData); @@ -284,6 +289,7 @@ class Simplify_SystemException extends Simplify_ApiException { /** * @ignore + * @param string $message */ function __construct($message, $status = null, $errorData = null) { parent::__construct($message, $status, $errorData); diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Http.php b/includes/gateways/simplify-commerce/includes/Simplify/Http.php index a1359b21611..ff65273f8f4 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Http.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Http.php @@ -58,6 +58,9 @@ class Simplify_HTTP "get" => self::GET, "delete" => self::DELETE); + /** + * @param string $url + */ private function request($url, $method, $authentication, $payload = '') { if ($authentication->publicKey == null) { @@ -126,7 +129,7 @@ class Simplify_HTTP /** * Handles Simplify API requests * - * @param $url + * @param string $url * @param $method * @param $authentication * @param string $payload @@ -167,9 +170,9 @@ class Simplify_HTTP /** * Handles Simplify OAuth requests * - * @param $url - * @param $payload - * @param $authentication + * @param string $url + * @param string $payload + * @param Simplify_Authentication $authentication * @return mixed * @throws Simplify_AuthenticationException * @throws Simplify_ObjectNotFoundException @@ -225,6 +228,9 @@ class Simplify_HTTP throw new Simplify_SystemException("An unexpected error has been raised. Looks like there's something wrong at our end." , $status, $object); } + /** + * @param Simplify_Authentication $authentication + */ public function jwsDecode($authentication, $hash) { if ($authentication->publicKey == null) { @@ -271,6 +277,10 @@ class Simplify_HTTP } } + /** + * @param string $payload + * @param boolean $hasPayload + */ private function jwsEncode($authentication, $url, $payload, $hasPayload) { // TODO - better seeding of RNG @@ -299,6 +309,9 @@ class Simplify_HTTP return $msg . "." . $this->jwsSign($authentication->privateKey, $msg); } + /** + * @param string $msg + */ private function jwsSign($privateKey, $msg) { $decodedPrivateKey = $this->jwsUrlSafeDecode64($privateKey); $sig = hash_hmac('sha256', $msg, $decodedPrivateKey, true); @@ -306,6 +319,9 @@ class Simplify_HTTP return $this->jwsUrlSafeEncode64($sig); } + /** + * @param string $header + */ private function jwsVerifyHeader($header, $url, $publicKey) { $hdr = json_decode($header, true); @@ -359,10 +375,16 @@ class Simplify_HTTP } + /** + * @param string $msg + */ private function jwsVerifySignature($privateKey, $msg, $expectedSig) { return $this->jwsSign($privateKey, $msg) == $expectedSig; } + /** + * @param string $reason + */ private function jwsAuthError($reason) { throw new Simplify_AuthenticationException("JWS authentication failure: " . $reason); } @@ -376,6 +398,9 @@ class Simplify_HTTP return strpos($k, "lvpb") === 0; } + /** + * @param string $s + */ private function jwsUrlSafeEncode64($s) { return str_replace(array('+', '/', '='), array('-', '_', ''), @@ -395,6 +420,9 @@ class Simplify_HTTP return base64_decode(str_replace(array('-', '_'), array('+', '/'), $s)); } + /** + * @param string $msg + */ private function buildOauthError($msg, $error, $error_description){ return array( diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Invoice.php b/includes/gateways/simplify-commerce/includes/Simplify/Invoice.php index e079be98b7e..a17cc3844f2 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Invoice.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Invoice.php @@ -37,7 +37,7 @@ class Simplify_Invoice extends Simplify_Object { *
offset
Used in paging of the list. This is the start offset of the page. [default: 0]
*
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id invoiceDate customer amount processedDate.
* @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Invoice objects and the total + * @return Simplify_ResourceList a ResourceList object that holds the list of Invoice objects and the total * number of Invoice objects available for the given criteria. * @see ResourceList */ diff --git a/includes/gateways/simplify-commerce/includes/Simplify/InvoiceItem.php b/includes/gateways/simplify-commerce/includes/Simplify/InvoiceItem.php index 555b771a231..46d24e4b0b8 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/InvoiceItem.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/InvoiceItem.php @@ -77,7 +77,7 @@ class Simplify_InvoiceItem extends Simplify_Object { *
offset
Used in paging of the list. This is the start offset of the page. [default: 0]
*
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id amount description invoice.
* @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of InvoiceItem objects and the total + * @return Simplify_ResourceList a ResourceList object that holds the list of InvoiceItem objects and the total * number of InvoiceItem objects available for the given criteria. * @see ResourceList */ diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Payment.php b/includes/gateways/simplify-commerce/includes/Simplify/Payment.php index 051f3f7cf7f..58770251186 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Payment.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Payment.php @@ -73,7 +73,7 @@ class Simplify_Payment extends Simplify_Object { *
offset
Used in paging of the list. This is the start offset of the page. [default: 0]
*
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated amount id description paymentDate.
* @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Payment objects and the total + * @return Simplify_ResourceList a ResourceList object that holds the list of Payment objects and the total * number of Payment objects available for the given criteria. * @see ResourceList */ diff --git a/includes/gateways/simplify-commerce/includes/Simplify/PaymentsApi.php b/includes/gateways/simplify-commerce/includes/Simplify/PaymentsApi.php index 6b7c83717ba..ff8c49be6ab 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/PaymentsApi.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/PaymentsApi.php @@ -43,6 +43,7 @@ class Simplify_PaymentsApi /** * @ignore + * @param Simplify_Authentication $authentication */ static public function createObject($object, $authentication = null) { @@ -57,6 +58,7 @@ class Simplify_PaymentsApi /** * @ignore + * @param Simplify_Authentication $authentication */ static public function findObject($object, $authentication = null) { @@ -70,6 +72,7 @@ class Simplify_PaymentsApi /** * @ignore + * @param Simplify_Authentication $authentication */ static public function updateObject($object, $authentication = null) { $paymentsApi = new Simplify_PaymentsApi(); @@ -82,6 +85,7 @@ class Simplify_PaymentsApi /** * @ignore + * @param Simplify_Authentication $authentication */ static public function deleteObject($object, $authentication = null) { $paymentsApi = new Simplify_PaymentsApi(); @@ -93,6 +97,7 @@ class Simplify_PaymentsApi /** * @ignore + * @param Simplify_Authentication $authentication */ static public function listObject($object, $criteria = null, $authentication =null) { if ($criteria != null) { @@ -154,6 +159,7 @@ class Simplify_PaymentsApi /** * @ignore + * @param string $action */ public function getUrl($publicKey, $action, $object) { @@ -195,6 +201,7 @@ class Simplify_PaymentsApi /** * @ignore + * @param string $action */ public function getMethod($action) { @@ -206,6 +213,8 @@ class Simplify_PaymentsApi /** * @ignore + * @param string $action + * @param Simplify_Authentication|null $authentication */ private function execute($action, $object, $authentication) { @@ -217,6 +226,7 @@ class Simplify_PaymentsApi /** * @ignore + * @param Simplify_Authentication $authentication */ public function jwsDecode($hash, $authentication) { @@ -247,6 +257,7 @@ class Simplify_PaymentsApi /** * @ignore + * @param string $c */ private function endsWith($s, $c) { @@ -262,7 +273,7 @@ class Simplify_PaymentsApi * @ignore * @param $authentication * @param $args - * @param $expectedArgCount + * @param integer $expectedArgCount * @return Simplify_Authentication */ static function buildAuthenticationObject($authentication = null, $args, $expectedArgCount){ diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Plan.php b/includes/gateways/simplify-commerce/includes/Simplify/Plan.php index e567ca75add..6c6fd9729f4 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Plan.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Plan.php @@ -77,7 +77,7 @@ class Simplify_Plan extends Simplify_Object { *
offset
Used in paging of the list. This is the start offset of the page. [default: 0]
*
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated amount frequency name id.
* @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Plan objects and the total + * @return Simplify_ResourceList a ResourceList object that holds the list of Plan objects and the total * number of Plan objects available for the given criteria. * @see ResourceList */ diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Refund.php b/includes/gateways/simplify-commerce/includes/Simplify/Refund.php index 637a3833a32..ac13e14e565 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Refund.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Refund.php @@ -60,7 +60,7 @@ class Simplify_Refund extends Simplify_Object { *
offset
Used in paging of the list. This is the start offset of the page. [default: 0]
*
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id amount description dateCreated paymentDate.
* @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Refund objects and the total + * @return Simplify_ResourceList a ResourceList object that holds the list of Refund objects and the total * number of Refund objects available for the given criteria. * @see ResourceList */ diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Subscription.php b/includes/gateways/simplify-commerce/includes/Simplify/Subscription.php index 0c0b2bc8389..c62964de20b 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Subscription.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Subscription.php @@ -81,7 +81,7 @@ class Simplify_Subscription extends Simplify_Object { *
offset
Used in paging of the list. This is the start offset of the page. [default: 0]
*
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id plan.
* @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Subscription objects and the total + * @return Simplify_ResourceList a ResourceList object that holds the list of Subscription objects and the total * number of Subscription objects available for the given criteria. * @see ResourceList */ diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Webhook.php b/includes/gateways/simplify-commerce/includes/Simplify/Webhook.php index 2d7576aefb3..180846e08af 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Webhook.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Webhook.php @@ -74,7 +74,7 @@ class Simplify_Webhook extends Simplify_Object { *
offset
Used in paging of the list. This is the start offset of the page. [default: 0]
*
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated.
* @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Webhook objects and the total + * @return Simplify_ResourceList a ResourceList object that holds the list of Webhook objects and the total * number of Webhook objects available for the given criteria. * @see ResourceList */ diff --git a/includes/walkers/class-product-cat-dropdown-walker.php b/includes/walkers/class-product-cat-dropdown-walker.php index 27414000a26..2da0d76ba08 100644 --- a/includes/walkers/class-product-cat-dropdown-walker.php +++ b/includes/walkers/class-product-cat-dropdown-walker.php @@ -21,7 +21,6 @@ class WC_Product_Cat_Dropdown_Walker extends Walker { * @since 2.1.0 * * @param string $output Passed by reference. Used to append additional content. - * @param object $category Category data object. * @param int $depth Depth of category in reference to parents. * @param integer $current_object_id */ diff --git a/includes/walkers/class-product-cat-list-walker.php b/includes/walkers/class-product-cat-list-walker.php index 310d44cf984..da05a41b55b 100644 --- a/includes/walkers/class-product-cat-list-walker.php +++ b/includes/walkers/class-product-cat-list-walker.php @@ -53,7 +53,6 @@ class WC_Product_Cat_List_Walker extends Walker { * @since 2.1.0 * * @param string $output Passed by reference. Used to append additional content. - * @param object $category Category data object. * @param int $depth Depth of category in reference to parents. * @param integer $current_object_id */ @@ -84,7 +83,6 @@ class WC_Product_Cat_List_Walker extends Walker { * @since 2.1.0 * * @param string $output Passed by reference. Used to append additional content. - * @param object $page Not used. * @param int $depth Depth of category. Not used. * @param array $args Only uses 'list' for whether should append to output. */ diff --git a/includes/wc-cart-functions.php b/includes/wc-cart-functions.php index 0c873c35563..34ddbe48049 100644 --- a/includes/wc-cart-functions.php +++ b/includes/wc-cart-functions.php @@ -44,7 +44,7 @@ function wc_empty_cart() { * Load the cart upon login * * @param mixed $user_login - * @param mixed $user + * @param integer $user * @return void */ function wc_load_persistent_cart( $user_login, $user = 0 ) { diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php index 03a8956c21b..1320d2bd826 100644 --- a/includes/wc-core-functions.php +++ b/includes/wc-core-functions.php @@ -114,7 +114,7 @@ function wc_create_order( $args = array() ) { /** * Update an order. Uses wc_create_order. * @param array $args - * @return WC_Error | WC_Order + * @return string | WC_Order */ function wc_update_order( $args ) { if ( ! $args['order_id'] ) { @@ -590,7 +590,7 @@ add_filter( 'mod_rewrite_rules', 'wc_ms_protect_download_rewite_rules' ); * WooCommerce Core Supported Themes * * @since 2.2 - * @return array + * @return string[] */ function wc_get_core_supported_themes() { return array( 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ); diff --git a/includes/wc-formatting-functions.php b/includes/wc-formatting-functions.php index a2a43f29c32..c5a960920a1 100644 --- a/includes/wc-formatting-functions.php +++ b/includes/wc-formatting-functions.php @@ -17,7 +17,6 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly * * urldecode is used to reverse munging of UTF8 characters. * - * @access public * @param mixed $taxonomy * @return string */ @@ -28,7 +27,6 @@ function wc_sanitize_taxonomy_name( $taxonomy ) { /** * Gets the filename part of a download URL * - * @access public * @param string $file_url * @return string */ @@ -44,7 +42,6 @@ function wc_get_filename_from_url( $file_url ) { * * Usage: wc_get_dimension(55, 'in'); * - * @access public * @param mixed $dim * @param mixed $to_unit 'in', 'm', 'cm', 'm' * @return float @@ -92,11 +89,10 @@ function wc_get_dimension( $dim, $to_unit ) { } /** - * Normalise weights, unify to cm then convert to wanted unit value + * Normalise weights, unify to kg then convert to wanted unit value * * Usage: wc_get_weight(55, 'kg'); * - * @access public * @param mixed $weight * @param mixed $to_unit 'g', 'kg', 'lbs' * @return float @@ -140,7 +136,6 @@ function wc_get_weight( $weight, $to_unit ) { /** * Trim trailing zeros off prices. * - * @access public * @param mixed $price * @return string */ @@ -151,16 +146,17 @@ function wc_trim_zeros( $price ) { /** * Round a tax amount * - * @access public - * @param mixed $price - * @return string + * @param mixed $tax + * @return double */ function wc_round_tax_total( $tax ) { $dp = (int) get_option( 'woocommerce_price_num_decimals' ); + // @codeCoverageIgnoreStart if ( version_compare( phpversion(), '5.3', '<' ) ) { $tax = round( $tax, $dp ); } else { + // @codeCoverageIgnoreEnd $tax = round( $tax, $dp, WC_TAX_ROUNDING_MODE ); } return $tax; @@ -244,7 +240,6 @@ function wc_format_localized_decimal( $value ) { /** * Clean variables * - * @access public * @param string $var * @return string */ @@ -255,23 +250,22 @@ function wc_clean( $var ) { /** * Merge two arrays * - * @access public * @param array $a1 * @param array $a2 * @return array */ function wc_array_overlay( $a1, $a2 ) { - foreach( $a1 as $k => $v ) { - if ( ! array_key_exists( $k, $a2 ) ) { - continue; - } - if ( is_array( $v ) && is_array( $a2[ $k ] ) ) { - $a1[ $k ] = wc_array_overlay( $v, $a2[ $k ] ); - } else { - $a1[ $k ] = $a2[ $k ]; - } - } - return $a1; + foreach ( $a1 as $k => $v ) { + if ( ! array_key_exists( $k, $a2 ) ) { + continue; + } + if ( is_array( $v ) && is_array( $a2[ $k ] ) ) { + $a1[ $k ] = wc_array_overlay( $v, $a2[ $k ] ); + } else { + $a1[ $k ] = $a2[ $k ]; + } + } + return $a1; } /** @@ -312,7 +306,6 @@ function get_woocommerce_price_format() { /** * Format the price with a currency symbol. * - * @access public * @param float $price * @param array $args (default: array()) * @return string @@ -358,32 +351,30 @@ function wc_price( $price, $args = array() ) { * * This function transforms the php.ini notation for numbers (like '2M') to an integer. * - * @access public * @param $size * @return int */ function wc_let_to_num( $size ) { - $l = substr( $size, -1 ); - $ret = substr( $size, 0, -1 ); - switch( strtoupper( $l ) ) { - case 'P': - $ret *= 1024; - case 'T': - $ret *= 1024; - case 'G': - $ret *= 1024; - case 'M': - $ret *= 1024; - case 'K': - $ret *= 1024; - } - return $ret; + $l = substr( $size, -1 ); + $ret = substr( $size, 0, -1 ); + switch ( strtoupper( $l ) ) { + case 'P': + $ret *= 1024; + case 'T': + $ret *= 1024; + case 'G': + $ret *= 1024; + case 'M': + $ret *= 1024; + case 'K': + $ret *= 1024; + } + return $ret; } /** * WooCommerce Date Format - Allows to change date format for everything WooCommerce * - * @access public * @return string */ function wc_date_format() { @@ -393,7 +384,6 @@ function wc_date_format() { /** * WooCommerce Time Format - Allows to change time format for everything WooCommerce * - * @access public * @return string */ function wc_time_format() { @@ -407,7 +397,6 @@ function wc_time_format() { * Adapted from http://www.php.net/manual/en/function.timezone-name-from-abbr.php#89155 * * @since 2.1 - * @access public * @return string a valid PHP timezone string for the site */ function wc_timezone_string() { @@ -452,7 +441,6 @@ if ( ! function_exists( 'wc_rgb_from_hex' ) ) { /** * Hex darker/lighter/contrast functions for colours * - * @access public * @param mixed $color * @return string */ @@ -473,26 +461,25 @@ if ( ! function_exists( 'wc_hex_darker' ) ) { /** * Hex darker/lighter/contrast functions for colours * - * @access public * @param mixed $color * @param int $factor (default: 30) * @return string */ function wc_hex_darker( $color, $factor = 30 ) { - $base = wc_rgb_from_hex( $color ); + $base = wc_rgb_from_hex( $color ); $color = '#'; - foreach ($base as $k => $v) : - $amount = $v / 100; - $amount = round($amount * $factor); - $new_decimal = $v - $amount; + foreach ( $base as $k => $v ) { + $amount = $v / 100; + $amount = round( $amount * $factor ); + $new_decimal = $v - $amount; - $new_hex_component = dechex($new_decimal); - if(strlen($new_hex_component) < 2) : - $new_hex_component = "0".$new_hex_component; - endif; - $color .= $new_hex_component; - endforeach; + $new_hex_component = dechex( $new_decimal ); + if ( strlen( $new_hex_component ) < 2 ) { + $new_hex_component = "0" . $new_hex_component; + } + $color .= $new_hex_component; + } return $color; } @@ -503,29 +490,28 @@ if ( ! function_exists( 'wc_hex_lighter' ) ) { /** * Hex darker/lighter/contrast functions for colours * - * @access public * @param mixed $color * @param int $factor (default: 30) * @return string */ function wc_hex_lighter( $color, $factor = 30 ) { - $base = wc_rgb_from_hex( $color ); + $base = wc_rgb_from_hex( $color ); $color = '#'; - foreach ($base as $k => $v) : - $amount = 255 - $v; - $amount = $amount / 100; - $amount = round($amount * $factor); - $new_decimal = $v + $amount; + foreach ( $base as $k => $v ) { + $amount = 255 - $v; + $amount = $amount / 100; + $amount = round( $amount * $factor ); + $new_decimal = $v + $amount; - $new_hex_component = dechex($new_decimal); - if(strlen($new_hex_component) < 2) : - $new_hex_component = "0".$new_hex_component; - endif; - $color .= $new_hex_component; - endforeach; + $new_hex_component = dechex( $new_decimal ); + if ( strlen( $new_hex_component ) < 2 ) { + $new_hex_component = "0" . $new_hex_component; + } + $color .= $new_hex_component; + } - return $color; + return $color; } } @@ -534,19 +520,19 @@ if ( ! function_exists( 'wc_light_or_dark' ) ) { /** * Detect if we should use a light or dark colour on a background colour * - * @access public * @param mixed $color * @param string $dark (default: '#000000') * @param string $light (default: '#FFFFFF') * @return string */ function wc_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { - //return ( hexdec( $color ) > 0xffffff / 2 ) ? $dark : $light; - $hex = str_replace( '#', '', $color ); + + $hex = str_replace( '#', '', $color ); $c_r = hexdec( substr( $hex, 0, 2 ) ); $c_g = hexdec( substr( $hex, 2, 2 ) ); $c_b = hexdec( substr( $hex, 4, 2 ) ); + $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; return $brightness > 155 ? $dark : $light; @@ -558,28 +544,27 @@ if ( ! function_exists( 'wc_format_hex' ) ) { /** * Format string as hex * - * @access public * @param string $hex * @return string */ function wc_format_hex( $hex ) { - $hex = trim( str_replace( '#', '', $hex ) ); + $hex = trim( str_replace( '#', '', $hex ) ); - if ( strlen( $hex ) == 3 ) { + if ( strlen( $hex ) == 3 ) { $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; - } + } - if ( $hex ) return '#' . $hex; + return $hex ? '#' . $hex : null; } } /** * Format the postcode according to the country and length of the postcode * - * @param string postcode - * @param string country - * @return string formatted postcode + * @param string postcode + * @param string country + * @return string formatted postcode */ function wc_format_postcode( $postcode, $country ) { $postcode = strtoupper( trim( $postcode ) ); @@ -595,7 +580,6 @@ function wc_format_postcode( $postcode, $country ) { /** * format_phone function. * - * @access public * @param mixed $tel * @return string */ diff --git a/includes/wc-notice-functions.php b/includes/wc-notice-functions.php index a2dc2522dd6..280e6cc7b90 100644 --- a/includes/wc-notice-functions.php +++ b/includes/wc-notice-functions.php @@ -13,10 +13,11 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly /** - * Get the count of notices added, either for all notices (default) or for one particular notice type specified - * by $notice_type. + * Get the count of notices added, either for all notices (default) or for one + * particular notice type specified by $notice_type. * - * @param string $notice_type The name of the notice type - either error, success or notice. [optional] + * @since 2.1 + * @param string $notice_type The name of the notice type - either error, success or notice. [optional] * @return int */ function wc_notice_count( $notice_type = '' ) { @@ -39,10 +40,11 @@ function wc_notice_count( $notice_type = '' ) { } /** - * See if a notice has already been added + * Check if a notice has already been added * - * @param string $message The text to display in the notice. - * @param string $notice_type The singular name of the notice type - either error, success or notice. [optional] + * @since 2.1 + * @param string $message The text to display in the notice. + * @param string $notice_type The singular name of the notice type - either error, success or notice. [optional] * @return bool */ function wc_has_notice( $message, $notice_type = 'success' ) { @@ -54,16 +56,18 @@ function wc_has_notice( $message, $notice_type = 'success' ) { /** * Add and store a notice * - * @param string $message The text to display in the notice. - * @param string $notice_type The singular name of the notice type - either error, success or notice. [optional] + * @since 2.1 + * @param string $message The text to display in the notice. + * @param string $notice_type The singular name of the notice type - either error, success or notice. [optional] */ function wc_add_notice( $message, $notice_type = 'success' ) { $notices = WC()->session->get( 'wc_notices', array() ); // Backward compatibility - if ( 'success' === $notice_type ) + if ( 'success' === $notice_type ) { $message = apply_filters( 'woocommerce_add_message', $message ); + } $notices[$notice_type][] = apply_filters( 'woocommerce_add_' . $notice_type, $message ); @@ -105,13 +109,15 @@ add_action( 'woocommerce_before_single_product', 'wc_print_notices', 10 ); /** * Print a single notice immediately * - * @param string $message The text to display in the notice. - * @param string $notice_type The singular name of the notice type - either error, success or notice. [optional] + * @since 2.1 + * @param string $message The text to display in the notice. + * @param string $notice_type The singular name of the notice type - either error, success or notice. [optional] */ function wc_print_notice( $message, $notice_type = 'success' ) { - if ( 'success' === $notice_type ) + if ( 'success' === $notice_type ) { $message = apply_filters( 'woocommerce_add_message', $message ); + } wc_get_template( "notices/{$notice_type}.php", array( 'messages' => array( apply_filters( 'woocommerce_add_' . $notice_type, $message ) ) @@ -120,7 +126,9 @@ function wc_print_notice( $message, $notice_type = 'success' ) { /** * Returns all queued notices, optionally filtered by a notice type. - * @param string $notice_type The singular name of the notice type - either error, success or notice. [optional] + * + * @since 2.1 + * @param string $notice_type The singular name of the notice type - either error, success or notice. [optional] * @return array|mixed */ function wc_get_notices( $notice_type = '' ) { diff --git a/includes/wc-order-functions.php b/includes/wc-order-functions.php index 1045dde0e06..6fa65567b55 100644 --- a/includes/wc-order-functions.php +++ b/includes/wc-order-functions.php @@ -31,6 +31,22 @@ function wc_get_order_statuses() { return apply_filters( 'wc_order_statuses', $order_statuses ); } +/** + * Get the order status label. + * + * @since 2.2 + * @param string $status + * @return string + */ +function wc_get_order_status_label( $status ) { + $order_statuses = wc_get_order_statuses(); + + $status = str_replace( 'wc-', '', $status ); + $status = isset( $order_statuses[ 'wc-' . $status ] ) ? $order_statuses[ 'wc-' . $status ] : $status; + + return $status; +} + /** * Main function for returning orders, uses the WC_Order_Factory class. * @@ -305,7 +321,6 @@ add_action( 'woocommerce_order_status_processing', 'wc_downloadable_product_perm * * @access public * @param int $order_id - * @param array $data * @return mixed */ function wc_add_order_item( $order_id, $item ) { diff --git a/includes/wc-page-functions.php b/includes/wc-page-functions.php index b09e90fecf3..044d17e62c4 100644 --- a/includes/wc-page-functions.php +++ b/includes/wc-page-functions.php @@ -39,7 +39,6 @@ function wc_get_page_id( $page ) { * * Gets the URL for an endpoint, which varies depending on permalink settings. * - * @param string $page * @return string */ function wc_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) { @@ -94,7 +93,6 @@ function wc_edit_address_i18n( $id, $flip = false ) { * Returns the url to the lost password endpoint url * * @access public - * @param string $url * @return string */ function wc_lostpassword_url() { diff --git a/includes/wc-product-functions.php b/includes/wc-product-functions.php index c8a56a7bea3..767c78ed1f3 100644 --- a/includes/wc-product-functions.php +++ b/includes/wc-product-functions.php @@ -273,7 +273,7 @@ function wc_placeholder_img( $size = 'shop_thumbnail' ) { * Gets a formatted version of variation data or item meta * * @access public - * @param array $variation + * @param string $variation * @param bool $flat (default: false) * @return string */ diff --git a/includes/wc-template-functions.php b/includes/wc-template-functions.php index 0e48d1464d6..72eb937ff04 100644 --- a/includes/wc-template-functions.php +++ b/includes/wc-template-functions.php @@ -1403,7 +1403,7 @@ if ( ! function_exists( 'woocommerce_product_subcategories' ) ) { * @access public * @subpackage Loop * @param array $args - * @return bool + * @return null|boolean */ function woocommerce_product_subcategories( $args = array() ) { global $wp_query; diff --git a/includes/wc-term-functions.php b/includes/wc-term-functions.php index 0c84748b0d2..ee0db2316fe 100644 --- a/includes/wc-term-functions.php +++ b/includes/wc-term-functions.php @@ -100,9 +100,7 @@ function _wc_get_product_terms_parent_usort_callback( $a, $b ) { * Stuck with this until a fix for http://core.trac.wordpress.org/ticket/13258 * We use a custom walker, just like WordPress does * - * @param int $show_counts (default: 1) - * @param int $hierarchical (default: 1) - * @param int $show_uncategorized (default: 1) + * @param int $deprecated_show_uncategorized (default: 1) * @return string */ function wc_product_dropdown_categories( $args = array(), $deprecated_hierarchical = 1, $deprecated_show_uncategorized = 1, $deprecated_orderby = '' ) { @@ -198,7 +196,7 @@ add_action( 'switch_blog', 'wc_taxonomy_metadata_wpdbfix', 0 ); * WooCommerce Term Meta API - Update term meta * * @param mixed $term_id - * @param mixed $meta_key + * @param string $meta_key * @param mixed $meta_value * @param string $prev_value (default: '') * @return bool @@ -237,7 +235,7 @@ function delete_woocommerce_term_meta( $term_id, $meta_key, $meta_value = '', $d * WooCommerce Term Meta API - Get term meta * * @param mixed $term_id - * @param mixed $key + * @param string $key * @param bool $single (default: true) * @return mixed */ diff --git a/package.json b/package.json index 26405a9713e..f4893f947dd 100644 --- a/package.json +++ b/package.json @@ -10,16 +10,16 @@ "main": "Gruntfile.js", "devDependencies": { "grunt": "~0.4.5", - "grunt-contrib-uglify": "~0.5.1", - "grunt-contrib-less": "~0.11.4", - "grunt-contrib-cssmin": "~0.10.0", - "grunt-shell": "~0.7.0", - "grunt-contrib-watch": "~0.6.1", - "grunt-contrib-copy": "~0.5.0", - "grunt-contrib-clean": "~0.6.0", "grunt-checktextdomain": "^0.1.1", - "grunt-wp-i18n": "^0.4.7", - "grunt-contrib-jshint": "^0.10.0" + "grunt-contrib-clean": "~0.6.0", + "grunt-contrib-copy": "~0.5.0", + "grunt-contrib-cssmin": "~0.10.0", + "grunt-contrib-jshint": "^0.10.0", + "grunt-contrib-less": "~0.11.4", + "grunt-contrib-uglify": "~0.5.1", + "grunt-contrib-watch": "~0.6.1", + "grunt-shell": "^1.1.1", + "grunt-wp-i18n": "^0.4.8" }, "engines": { "node": ">=0.8.0", diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 00000000000..b6e6e951839 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,28 @@ + + + + + ./tests/unit-tests + + + + + ./apigen/ + ./i18n/ + ./templates/ + ./tests/ + ./tmp/ + + + + + + diff --git a/readme.txt b/readme.txt index ceacbec5f28..6442cc79c3d 100644 --- a/readme.txt +++ b/readme.txt @@ -1,10 +1,10 @@ === WooCommerce - excelling eCommerce === -Contributors: woothemes, mikejolley, jameskoster +Contributors: woothemes, mikejolley, jameskoster, claudiosanches Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, affiliate, store, sales, sell, shop, shopping, cart, checkout, configurable, variable, widgets, reports, download, downloadable, digital, inventory, stock, reports, shipping, tax Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal@woothemes.com&item_name=Donation+for+WooCommerce Requires at least: 3.8 -Tested up to: 3.9 -Stable tag: 2.1.10 +Tested up to: 4.0 +Stable tag: 2.2.0 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -99,7 +99,7 @@ For extending or theming WooCommerce, see our [codex](http://docs.woothemes.com/ = Where can I get support or talk to other users? = -If you get stuck, WooThemes customers can communicate with one another on the [WooThemes Community Forum](https://support.woothemes.com/hc/communities/public/topics) and non-customers can ask for help from other users on the [WordPress.org Community Forums](http://wordpress.org/support/plugin/woocommerce). +If you get stuck you can ask for help on the [WooThemes Community Forum](https://support.woothemes.com/hc/communities/public/topics). For help with premium add-ons from WooThemes, use [our helpdesk](http://support.woothemes.com/). @@ -151,6 +151,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc * Tweak - Load archive-product.php for other product taxonomies. * Tweak - Disable image size settings if filters are being used. * Tweak - Hide the shipping address when local pickup is used. +* Tweak - Password protected posts are not hidden from catalog by default anymore, visibility can be set via the 'Catalog visibility' option. * Dev - API Version 2 with push support. * Dev - API: Lookup customers by email endpoint. * Dev - API: Allow ordering on the resource level. diff --git a/tests/README.md b/tests/README.md index 28ee6acf616..860e0a08c85 100644 --- a/tests/README.md +++ b/tests/README.md @@ -6,13 +6,13 @@ $ phpunit --version -2) Install WordPress and the WP Unit Test lib using the `install-wp-tests.sh` script. Change to the plugin root directory and type: +2) Install WordPress and the WP Unit Test lib using the `install.sh` script. Change to the plugin root directory and type: - $ tests/install-wp-tests.sh [db-host] + $ tests/bin/install.sh [db-host] Sample usage: - $ tests/install-wp-tests.sh woocommerce_tests root root + $ tests/bin/install.sh woocommerce_tests root root **Important**: The `` database will be created if it doesn't exist and all data will be removed during testing. @@ -34,8 +34,20 @@ A text code coverage summary can be displayed using the `--coverage-text` option ## Writing Tests -TODO +* Each test file should roughly correspond to an associated source file, e.g. the `formatting-functions.php` test file covers code in the `wc-formatting-functions.php` file +* Each test method should cover a single method or function with one or more assertions +* A single method or function can have multiple associated test methods if it's a large or complex method +* Use the test coverage HTML report (under `tmp/coverage/index.html`) to examine which lines your tests are covering and aim for 100% coverage +* For code that cannot be tested (e.g. they require a certain PHP version), you can exclude them from coverage using a comment: `// @codeCoverageIgnoreStart` and `// @codeCoverageIgnoreEnd`. For example, see [`wc_round_tax_total()`](https://github.com/woothemes/woocommerce/blob/master/includes/wc-formatting-functions.php#L155-155) +* In addition to covering each line of a method/function, make sure to test common input and edge cases. +* Prefer `assertsEquals()` where possible as it tests both type & equality +* Remember that only methods prefixed with `test` will be run so use helper methods liberally to keep test methods small and reduce code duplication. If there is a common helper method used in multiple test files, consider adding it to the `WC_Unit_Test_Case` class so it can be shared by all test cases +* Filters persist between test cases so be sure to remove them in your test method or in the `tearDown()` method. ## Automated Tests -Tests are automatically run with Travis-CI for each commit and pull request. +Tests are automatically run with [Travis-CI](https://travis-ci.org) for each commit and pull request. + +## Code Coverage + +Code coverage is available on [Coveralls](https://coveralls.io/) which receives updated data after each Travis build. diff --git a/tests/install-wp-tests.sh b/tests/bin/install.sh old mode 100644 new mode 100755 similarity index 89% rename from tests/install-wp-tests.sh rename to tests/bin/install.sh index 90f2670ba01..816179745a3 --- a/tests/install-wp-tests.sh +++ b/tests/bin/install.sh @@ -16,7 +16,6 @@ WP_VERSION=${5-latest} WP_TESTS_DIR="${PWD}/tmp/wordpress-tests-lib" WP_CORE_DIR="${PWD}/tmp/wordpress/" - set -ex install_wp() { @@ -55,6 +54,10 @@ install_test_suite() { sed $ioption "s/yourusernamehere/$DB_USER/" wp-tests-config.php sed $ioption "s/yourpasswordhere/$DB_PASS/" wp-tests-config.php sed $ioption "s|localhost|${DB_HOST}|" wp-tests-config.php + sed $ioption "s/wptests_/wctests_/" wp-tests-config.php + sed $ioption "s/example.org/woocommerce.com/" wp-tests-config.php + sed $ioption "s/admin@example.org/tests@woocommerce.com/" wp-tests-config.php + sed $ioption "s/Test Blog/WooCommerce Unit Tests/" wp-tests-config.php } install_db() { diff --git a/tests/bin/travis.sh b/tests/bin/travis.sh new file mode 100644 index 00000000000..e9960a45f95 --- /dev/null +++ b/tests/bin/travis.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# usage: travis.sh before|after + +if [ $1 == 'before' ]; then + + # composer install fails in PHP 5.2 + [ $TRAVIS_PHP_VERSION == '5.2' ] && exit; + + # install php-coveralls to send coverage info + composer init --require=satooshi/php-coveralls:0.7.x-dev -n + composer install --no-interaction + +elif [ $1 == 'after' ]; then + + # no Xdebug and therefore no coverage in PHP 5.2 + [ $TRAVIS_PHP_VERSION == '5.2' ] && exit; + + # send coverage data to coveralls + php vendor/bin/coveralls --verbose --exclude-no-stmt +fi diff --git a/tests/bootstrap.php b/tests/bootstrap.php index aebb20063c6..69bb3e3f1ea 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -84,7 +84,15 @@ class WC_Unit_Tests_Bootstrap { */ public function includes() { - require_once( $this->tests_dir . '/framework/wc-unit-test-factory.php' ); + // factories + require_once( $this->tests_dir . '/framework/factories/class-wc-unit-test-factory-for-webhook.php' ); + require_once( $this->tests_dir . '/framework/factories/class-wc-unit-test-factory-for-webhook-delivery.php' ); + + // framework + require_once( $this->tests_dir . '/framework/class-wc-unit-test-factory.php' ); + require_once( $this->tests_dir . '/framework/class-wc-mock-session-handler.php' ); + + // test cases require_once( $this->tests_dir . '/framework/class-wc-unit-test-case.php' ); require_once( $this->tests_dir . '/framework/class-wc-api-unit-test-case.php' ); } diff --git a/tests/framework/class-wc-mock-session-handler.php b/tests/framework/class-wc-mock-session-handler.php new file mode 100644 index 00000000000..bdc6f6a6f61 --- /dev/null +++ b/tests/framework/class-wc-mock-session-handler.php @@ -0,0 +1,7 @@ +factory = new WC_Unit_Test_Factory(); + + // setup mock WC session handler + add_filter( 'woocommerce_session_handler', array( $this, 'set_mock_session_handler' ) ); + + $this->setOutputCallback( array( $this, 'filter_output' ) ); + } + + /** + * Mock the WC session using the abstract class as cookies are not available + * during tests + * + * @since 2.2 + * @return string + */ + public function set_mock_session_handler() { + return 'WC_Mock_Session_Handler'; + } + + /** + * Strip newlines and tabs when using expectedOutputString() as otherwise + * the most template-related tests will fail due to indentation/alignment in + * the template not matching the sample strings set in the tests + * + * @since 2.2 + */ + public function filter_output( $output ) { + + $output = preg_replace( '/[\n]+/S', '', $output ); + $output = preg_replace( '/[\t]+/S', '', $output ); + + return $output; } /** @@ -36,4 +67,24 @@ class WC_Unit_Test_Case extends WP_UnitTestCase { $this->assertNotInstanceOf( 'WP_Error', $actual, $message ); } + /** + * Backport assertNotFalse to PHPUnit 3.6.12 which only runs in PHP 5.2 + * + * @since 2.2 + * @param $condition + * @param string $message + * @return mixed + */ + public static function assertNotFalse( $condition, $message = '' ) { + + if ( version_compare( phpversion(), '5.3', '<' ) ) { + + self::assertThat( $condition, self::logicalNot( self::isFalse() ), $message ); + + } else { + + parent::assertNotFalse( $condition, $message ); + } + } + } diff --git a/tests/framework/class-wc-unit-test-factory.php b/tests/framework/class-wc-unit-test-factory.php new file mode 100644 index 00000000000..ab65acff3af --- /dev/null +++ b/tests/framework/class-wc-unit-test-factory.php @@ -0,0 +1,28 @@ +webhook = new WC_Unit_Test_Factory_For_Webhook( $this ); + $this->webhook_delivery = new WC_Unit_Test_Factory_For_Webhook_Delivery( $this ); + } + +} diff --git a/tests/framework/wc-unit-test-factory.php b/tests/framework/factories/class-wc-unit-test-factory-for-webhook-delivery.php similarity index 78% rename from tests/framework/wc-unit-test-factory.php rename to tests/framework/factories/class-wc-unit-test-factory-for-webhook-delivery.php index 74202330e30..f9686364acc 100644 --- a/tests/framework/wc-unit-test-factory.php +++ b/tests/framework/factories/class-wc-unit-test-factory-for-webhook-delivery.php @@ -1,30 +1,8 @@ webhook_delivery = new WC_Unit_Test_Factory_For_Webhook_Delivery( $this ); - } -} - /** * Webhook Delivery Test Factory * + * @see \WP_UnitTest_Factory_For_Comment * @since 2.2 */ class WC_Unit_Test_Factory_For_Webhook_Delivery extends WP_UnitTest_Factory_For_Comment { diff --git a/tests/framework/factories/class-wc-unit-test-factory-for-webhook.php b/tests/framework/factories/class-wc-unit-test-factory-for-webhook.php new file mode 100644 index 00000000000..777547abfa6 --- /dev/null +++ b/tests/framework/factories/class-wc-unit-test-factory-for-webhook.php @@ -0,0 +1,71 @@ +default_generation_definitions = array( + 'post_status' => 'publish', + 'post_title' => rand_str(), + 'post_type' => 'shop_webhook', + ); + } + + /** + * Create a mock webhook + * + * @since 2.2 + * @see WP_UnitTest_Factory_For_Post::create_object() + * @param array $args + * @return int webhook (post) ID + */ + public function create_object( $args ) { + + $id = parent::create_object( $args ); + + $meta_args = array( + '_topic' => 'coupon.created', + '_resource' => 'coupon', + '_event' => 'created', + '_hooks' => array( + 'woocommerce_process_shop_coupon_meta', + 'woocommerce_api_create_coupon', + ), + '_delivery_url' => 'http://requestb.in/Tt8675309', + ); + + foreach ( $meta_args as $key => $value ) { + update_post_meta( $id, $key, $value ); + } + + return $id; + } + + /** + * Get a mock webhook object + * + * @since 2.2 + * @see WP_UnitTest_Factory_For_Post::get_object_by_id() + * @param int $id webhook ID + * @return \WC_Webhook webhook instance + */ + public function get_object_by_id( $id ) { + + return new WC_Webhook( $id ); + } + +} diff --git a/tests/unit-tests/api/webhooks.php b/tests/unit-tests/api/webhooks.php index 8f8935e96a7..4926cb0741b 100644 --- a/tests/unit-tests/api/webhooks.php +++ b/tests/unit-tests/api/webhooks.php @@ -28,31 +28,8 @@ class WC_Tests_Webhooks extends WC_API_Unit_Test_Case { $this->endpoint = WC()->api->WC_API_Webhooks; - $post_args = array( - 'post_type' => 'shop_webhook', - 'post_status' => 'publish', - 'post_title' => rand_str(), - ); - - $post_id = $this->factory->post->create( $post_args ); - - $meta_args = array( - '_topic' => 'coupon.created', - '_resource' => 'coupon', - '_event' => 'created', - '_hooks' => array( - 'woocommerce_process_shop_coupon_meta', - 'woocommerce_api_create_coupon', - ), - '_delivery_url' => rand_str(), - ); - - foreach ( $meta_args as $key => $value ) { - update_post_meta( $post_id, $key, $value ); - } - // mock webhook - $this->webhook = new WC_Webhook( $post_id ); + $this->webhook = $this->factory->webhook->create_and_get(); // mock webhook delivery $this->webhook_delivery_id = $this->factory->webhook_delivery->create( array( 'comment_post_ID' => $this->webhook->id ) ); diff --git a/tests/unit-tests/core-functions.php b/tests/unit-tests/core-functions.php index 7e84d698658..c3d08a56f08 100644 --- a/tests/unit-tests/core-functions.php +++ b/tests/unit-tests/core-functions.php @@ -101,11 +101,13 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case { */ public function test_get_woocommerce_api_url() { + $base_uri = get_home_url(); + // base uri - $this->assertEquals( 'http://example.org/wc-api/v2/', get_woocommerce_api_url( null ) ); + $this->assertEquals( "$base_uri/wc-api/v2/", get_woocommerce_api_url( null ) ); // path - $this->assertEquals( 'http://example.org/wc-api/v2/orders', get_woocommerce_api_url( 'orders' ) ); + $this->assertEquals( "$base_uri/wc-api/v2/orders", get_woocommerce_api_url( 'orders' ) ); } /** diff --git a/tests/unit-tests/coupon-functions.php b/tests/unit-tests/coupon-functions.php new file mode 100644 index 00000000000..ce0beb902b2 --- /dev/null +++ b/tests/unit-tests/coupon-functions.php @@ -0,0 +1,37 @@ + __( 'Cart Discount', 'woocommerce' ), + 'percent' => __( 'Cart % Discount', 'woocommerce' ), + 'fixed_product' => __( 'Product Discount', 'woocommerce' ), + 'percent_product' => __( 'Product % Discount', 'woocommerce' ) + ); + + $this->assertEquals( $coupon_types, wc_get_coupon_types() ); + } + + /** + * Test wc_get_coupon_type() + * + * @since 2.2 + */ + public function test_wc_get_coupon_type() { + + $this->assertEquals( 'Cart Discount', wc_get_coupon_type( 'fixed_cart' ) ); + $this->assertEmpty( wc_get_coupon_type( 'bogus_type' ) ); + } + +} diff --git a/tests/unit-tests/formatting-functions.php b/tests/unit-tests/formatting-functions.php new file mode 100644 index 00000000000..378ae0a6a3b --- /dev/null +++ b/tests/unit-tests/formatting-functions.php @@ -0,0 +1,523 @@ +assertEquals( 'name-with-spaces', wc_sanitize_taxonomy_name( 'Name With Spaces' ) ); + $this->assertEquals( 'namewithtabs', wc_sanitize_taxonomy_name( 'Name With Tabs' ) ); + $this->assertEquals( 'specialchars', wc_sanitize_taxonomy_name( 'special!@#$%^&*()chars' ) ); + $this->assertEquals( 'look-of-ಠ_ಠ', wc_sanitize_taxonomy_name( 'Look Of ಠ_ಠ' ) ); + } + + /** + * Test wc_get_filename_from_url() + * + * @since 2.2 + */ + public function test_wc_get_filename_from_url() { + + $this->assertEquals( 'woocommerce.pdf', wc_get_filename_from_url( 'http://www.woothemes.com/woocommerce.pdf' ) ); + $this->assertEmpty( wc_get_filename_from_url( 'ftp://wc' ) ); + $this->assertEmpty( wc_get_filename_from_url( 'http://www.skyverge.com' ) ); + $this->assertEquals( 'woocommerce', wc_get_filename_from_url( 'http://www.woothemes.com/woocommerce' ) ); + } + + /** + * Test wc_get_dimension() + * + * @since 2.2 + */ + public function test_wc_get_dimension() { + + // save default + $default_unit = get_option( 'woocommerce_dimension_unit' ); + + // cm (default unit) + $this->assertEquals( 10, wc_get_dimension( 10, 'cm' ) ); + $this->assertEquals( 3.937, wc_get_dimension( 10, 'in' ) ); + $this->assertEquals( 0.10936133, wc_get_dimension( 10, 'yd' ) ); + $this->assertEquals( 100, wc_get_dimension( 10, 'mm' ) ); + $this->assertEquals( 0.1, wc_get_dimension( 10, 'm' ) ); + + // in + update_option( 'woocommerce_dimension_unit', 'in' ); + $this->assertEquals( 25.4, wc_get_dimension( 10, 'cm' ) ); + $this->assertEquals( 10, wc_get_dimension( 10, 'in' ) ); + $this->assertEquals( 0.2777777782, wc_get_dimension( 10, 'yd' ) ); + $this->assertEquals( 254, wc_get_dimension( 10, 'mm' ) ); + $this->assertEquals( 0.254, wc_get_dimension( 10, 'm' ) ); + + // m + update_option( 'woocommerce_dimension_unit', 'm' ); + $this->assertEquals( 1000, wc_get_dimension( 10, 'cm' ) ); + $this->assertEquals( 393.7, wc_get_dimension( 10, 'in' ) ); + $this->assertEquals( 10.936133, wc_get_dimension( 10, 'yd' ) ); + $this->assertEquals( 10000, wc_get_dimension( 10, 'mm' ) ); + $this->assertEquals( 10, wc_get_dimension( 10, 'm' ) ); + + // mm + update_option( 'woocommerce_dimension_unit', 'mm' ); + $this->assertEquals( 1, wc_get_dimension( 10, 'cm' ) ); + $this->assertEquals( 0.3937, wc_get_dimension( 10, 'in' ) ); + $this->assertEquals( 0.010936133, wc_get_dimension( 10, 'yd' ) ); + $this->assertEquals( 10, wc_get_dimension( 10, 'mm' ) ); + $this->assertEquals( 0.01, wc_get_dimension( 10, 'm' ) ); + + // yd + update_option( 'woocommerce_dimension_unit', 'yd' ); + $this->assertEquals( 914.4, wc_get_dimension( 10, 'cm' ) ); + $this->assertEquals( 359.99928, wc_get_dimension( 10, 'in' ) ); + $this->assertEquals( 10, wc_get_dimension( 10, 'yd' ) ); + $this->assertEquals( 9144, wc_get_dimension( 10, 'mm' ) ); + $this->assertEquals( 9.144, wc_get_dimension( 10, 'm' ) ); + + // negative + $this->assertEquals( 0, wc_get_dimension( -10, 'mm' ) ); + + // restore default + update_option( 'woocommerce_dimension_unit', $default_unit ); + } + + /** + * Test wc_get_weight() + * + * @since 2.2 + */ + public function test_wc_get_weight() { + + // save default + $default_unit = get_option( 'woocommerce_weight_unit' ); + + // kg (default unit) + $this->assertEquals( 10, wc_get_weight( 10, 'kg' ) ); + $this->assertEquals( 10000, wc_get_weight( 10, 'g' ) ); + $this->assertEquals( 22.046, wc_get_weight( 10, 'lbs' ) ); + $this->assertEquals( 352.74, wc_get_weight( 10, 'oz' ) ); + + // g + update_option( 'woocommerce_weight_unit', 'g' ); + $this->assertEquals( 0.01, wc_get_weight( 10, 'kg' ) ); + $this->assertEquals( 10, wc_get_weight( 10, 'g' ) ); + $this->assertEquals( 0.022046, wc_get_weight( 10, 'lbs' ) ); + $this->assertEquals( 0.35274, wc_get_weight( 10, 'oz' ) ); + + // lbs + update_option( 'woocommerce_weight_unit', 'lbs' ); + $this->assertEquals( 4.536, wc_get_weight( 10, 'kg' ) ); + $this->assertEquals( 4536, wc_get_weight( 10, 'g' ) ); + $this->assertEquals( 10, wc_get_weight( 10, 'lbs' ) ); + $this->assertEquals( 160.002864, wc_get_weight( 10, 'oz' ) ); + + // oz + update_option( 'woocommerce_weight_unit', 'oz' ); + $this->assertEquals( 0.283, wc_get_weight( 10, 'kg' ) ); + $this->assertEquals( 283, wc_get_weight( 10, 'g' ) ); + $this->assertEquals( 0.6239018, wc_get_weight( 10, 'lbs' ) ); + $this->assertEquals( 10, wc_get_weight( 10, 'oz' ) ); + + // negative + $this->assertEquals( 0, wc_get_weight( -10, 'g' ) ); + + // restore default + update_option( 'woocommerce_weight_unit', $default_unit ); + } + + /** + * Test wc_trim_zeros() + * + * @since 2.2 + */ + public function test_wc_trim_zeros() { + + $this->assertEquals( '$1', wc_trim_zeros( '$1.00' ) ); + $this->assertEquals( '$1.10', wc_trim_zeros( '$1.10' ) ); + } + + /** + * Test wc_round_tax_total() + * + * Note the PHP 5.2 section of wc_round_tax_total() is excluded from test + * coverage + * + * @since 2.2 + */ + public function test_wc_round_tax_total() { + + $this->assertEquals( 1.25, wc_round_tax_total( 1.246 ) ); + $this->assertEquals( 20, wc_round_tax_total( 19.9997 ) ); + $this->assertEquals( 19.99, wc_round_tax_total( 19.99 ) ); + } + + /** + * Test wc_format_refund_total() + * + * @since 2.2 + */ + public function test_wc_format_refund_total() { + + $this->assertEquals( -10, wc_format_refund_total( 10 ) ); + $this->assertEquals( 10, wc_format_refund_total( -10 ) ); + } + + /** + * Test wc_format_decimal() + * + * @since 2.2 + */ + public function test_wc_format_decimal() { + + // given string + $this->assertEquals( '9.99', wc_format_decimal( '9.99' ) ); + + // float + $this->assertEquals( '9.99', wc_format_decimal( 9.99 ) ); + + // dp = false, no rounding + $this->assertEquals( '9.9999', wc_format_decimal( 9.9999 ) ); + + // dp = use default (2) + $this->assertEquals( '9.99', wc_format_decimal( 9.9911, '' ) ); + + // dp = use default (2) and round + $this->assertEquals( '10.00', wc_format_decimal( 9.9999, '' ) ); + + // dp = use custom + $this->assertEquals( '9.991', wc_format_decimal( 9.9912, 3 ) ); + + // trim zeros + $this->assertEquals( '9', wc_format_decimal( 9.00, false, true ) ); + + // trim zeros and round + $this->assertEquals( '10', wc_format_decimal( 9.9999, '', true ) ); + } + + /** + * Test wc_float_to_string() + * + * @since 2.2 + */ + public function test_wc_float_to_string() { + + // given string, return string + $this->assertEquals( '1.99', wc_float_to_string( '1.99' ) ); + + $this->assertEquals( '1.17', wc_float_to_string( 1.17 ) ); + } + + /** + * Test wc_format_localized_price() + * + * @since 2.2 + */ + public function test_wc_format_localized_price() { + + // save default + $decimal_sep = get_option( 'woocommerce_price_decimal_sep' ); + update_option( 'woocommerce_price_decimal_sep', ',' ); + + $this->assertEquals( '1,17', wc_format_localized_price( '1.17' ) ); + + // restore default + update_option( 'woocommerce_price_decimal_sep', $decimal_sep ); + } + + /** + * Test wc_format_localized_decimal() + * + * @since 2.2 + */ + public function test_wc_format_localized_decimal() { + + $this->assertEquals( '1.17', wc_format_localized_decimal( '1.17' ) ); + } + + /** + * Test wc_clean() - note this is a basic type test as WP core already + * has coverage for sanitized_text_field() + * + * @since 2.2 + */ + public function test_wc_clean() { + + $this->assertInternalType( 'string', wc_clean( 'cleaned' ) ); + } + + /** + * Test wc_array_overlay() + * + * @since 2.2 + */ + public function test_wc_array_overlay() { + + $a1 = array( + 'apple' => 'banana', + 'pear' => 'grape', + 'vegetables' => array( + 'cucumber' => 'asparagus', + ) + ); + + $a2 = array( + 'strawberry' => 'orange', + 'apple' => 'kiwi', + 'vegetables' => array( + 'cucumber' => 'peas', + ), + ); + + $overlayed = array( + 'apple' => 'kiwi', + 'pear' => 'grape', + 'vegetables' => array( + 'cucumber' => 'peas', + ), + ); + + $this->assertEquals( $overlayed, wc_array_overlay( $a1, $a2 ) ); + } + + /** + * Test wc_stock_amount() + * + * @since 2.2 + */ + public function test_wc_stock_amount() { + + $this->assertEquals( 10, wc_stock_amount( 10 ) ); + $this->assertEquals( 10, wc_stock_amount( '10' ) ); + $this->assertEquals( 3, wc_stock_amount( 3.43 ) ); + } + + /** + * Test wc_get_woocommerce_price_format() + * + * @since 2.2 + */ + public function test_get_woocommerce_price_format() { + + // save default + $currency_pos = get_option( 'woocommerce_currency_pos' ); + + // default format (left) + $this->assertEquals( '%1$s%2$s', get_woocommerce_price_format() ); + + // right + update_option( 'woocommerce_currency_pos', 'right' ); + $this->assertEquals( '%2$s%1$s', get_woocommerce_price_format() ); + + // left space + update_option( 'woocommerce_currency_pos', 'left_space' ); + $this->assertEquals( '%1$s %2$s', get_woocommerce_price_format() ); + + // right space + update_option( 'woocommerce_currency_pos', 'right_space' ); + $this->assertEquals( '%2$s %1$s', get_woocommerce_price_format() ); + + // restore default + update_option( 'woocommerce_currency_pos', $currency_pos ); + } + + /** + * Test wc_price() + * + * @since 2.2 + */ + public function test_wc_price() { + + // common prices + $this->assertEquals( '£1.00', wc_price( 1 ) ); + $this->assertEquals( '£1.10', wc_price( 1.1 ) ); + $this->assertEquals( '£1.17', wc_price( 1.17 ) ); + $this->assertEquals( '£1,111.17', wc_price( 1111.17 ) ); + $this->assertEquals( '£0.00', wc_price( 0 ) ); + + // different currency + $this->assertEquals( '$1,111.17', wc_price( 1111.17, array( 'currency' => 'USD' ) ) ); + + // negative price + $this->assertEquals( '-£1.17', wc_price( -1.17 ) ); + + // bogus prices + $this->assertEquals( '£0.00', wc_price( null ) ); + $this->assertEquals( '£0.00', wc_price( 'Q' ) ); + $this->assertEquals( '£0.00', wc_price( 'ಠ_ಠ' ) ); + + // trim zeros + add_filter( 'woocommerce_price_trim_zeros', '__return_true' ); + $this->assertEquals( '£1', wc_price( 1.00 ) ); + remove_filter( 'woocommerce_price_trim_zeros', '__return_true' ); + + // ex tax label + $calc_taxes = get_option( 'woocommerce_calc_taxes' ); + update_option( 'woocommerce_calc_taxes', 'yes' ); + $this->assertEquals( '£1,111.17 (ex. VAT)', wc_price( '1111.17', array( 'ex_tax_label' => true ) ) ); + update_option( 'woocommerce_calc_taxes', $calc_taxes ); + } + + /** + * Test wc_let_to_num() + * + * @since 2.2 + */ + public function test_wc_let_to_num() { + + $sizes = array( + '10K' => 10240, + '10M' => 10485760, + '10G' => 10737418240, + '10T' => 10995116277760, + '10P' => 11258999068426240, + ); + + foreach ( $sizes as $notation => $size ) { + $this->assertEquals( $size, wc_let_to_num( $notation ) ); + } + } + + /** + * Test wc_date_format() + * + * @since 2.2 + */ + public function test_wc_date_format() { + + $this->assertEquals( get_option( 'date_format' ), wc_date_format() ); + } + + /** + * Test wc_time_format() + * + * @since 2.2 + */ + public function test_wc_time_format() { + $this->assertEquals( get_option( 'time_format' ), wc_time_format() ); + } + + /** + * Test wc_timezone_string() + * + * @since 2.2 + */ + public function test_wc_timezone_string() { + + // test when timezone string exists + update_option( 'timezone_string', 'America/New_York' ); + $this->assertEquals( 'America/New_York', wc_timezone_string() ); + + // restore default + update_option( 'timezone_string', '' ); + + // test with missing UTC offset + delete_option( 'gmt_offset' ); + $this->assertEquals( 'UTC', wc_timezone_string() ); + + // test with manually set UTC offset + update_option( 'gmt_offset', -4 ); + $this->assertEquals( 'America/Boa_Vista', wc_timezone_string() ); + + // test with invalid offset + update_option( 'gmt_offset', 99 ); + $this->assertEquals( 'UTC', wc_timezone_string() ); + + // restore default + update_option( 'gmt_offset', '0' ); + } + + /** + * Test wc_rgb_from_hex() + * + * @since 2.2 + */ + public function test_wc_rgb_from_hex() { + + $rgb = array( + 'R' => 0, + 'G' => 93, + 'B' => 171, + ); + + $this->assertEquals( $rgb, wc_rgb_from_hex( '005dab' ) ); + $this->assertEquals( $rgb, wc_rgb_from_hex( '#005dab' ) ); + } + + /** + * Test wc_hex_darker() + * + * @since 2.2 + */ + public function test_wc_hex_darker() { + + $this->assertEquals( '#004178', wc_hex_darker( '005dab' ) ); + $this->assertEquals( '#004178', wc_hex_darker( '#005dab' ) ); + } + + /** + * Test wc_hex_lighter() + * + * @since 2.2 + */ + public function test_wc_hex_lighter() { + + $this->assertEquals( '#4d8ec4', wc_hex_lighter( '005dab' ) ); + $this->assertEquals( '#4d8ec4', wc_hex_lighter( '#005dab' ) ); + $this->assertEquals( '#0c3a3b', wc_hex_lighter( '0a3839', 1 ) ); + } + + /** + * Test wc_light_or_dark() + * + * @since 2.2 + */ + public function test_wc_light_or_dark() { + + $this->assertEquals( '#FFFFFF', wc_light_or_dark( '005dab' ) ); + $this->assertEquals( '#FFFFFF', wc_light_or_dark( '#005dab' ) ); + } + + /** + * Test wc_format_hex() + * + * @since 2.2 + */ + public function test_wc_format_hex() { + + $this->assertEquals( '#CCCCCC', wc_format_hex( 'CCC' ) ); + $this->assertEquals( '#CCCCCC', wc_format_hex( '#CCC' ) ); + $this->assertEquals( null, wc_format_hex( null ) ); + } + + /** + * Test wc_format_postcode() + * + * @since 2.2 + */ + public function test_wc_format_postcode() { + + // generic postcode + $this->assertEquals( '02111', wc_format_postcode( ' 02111 ', 'US' ) ); + + // UK postcode + $this->assertEquals( 'PCRN 1ZZ', wc_format_postcode( 'pcrn1zz', 'GB' ) ); + } + + /** + * Test wc_format_phone_number() + * + * @since 2.2 + */ + public function test_wc_format_phone_number() { + + $this->assertEquals( '1-610-385-0000', wc_format_phone_number( '1.610.385.0000' ) ); + } + +} diff --git a/tests/unit-tests/notice-functions.php b/tests/unit-tests/notice-functions.php new file mode 100644 index 00000000000..da55cec5cca --- /dev/null +++ b/tests/unit-tests/notice-functions.php @@ -0,0 +1,184 @@ +session->set( 'wc_notices', null ); + } + + /** + * Test wc_notice_count() + * + * @since 2.2 + */ + function test_wc_notice_count() { + + // no notices + $this->assertEquals( 0, wc_notice_count() ); + + // single notice + wc_add_notice( 'Bogus Notice', 'success' ); + $this->assertEquals( 1, wc_notice_count() ); + + // specific notice + wc_add_notice( 'Bogus Error Notice', 'error' ); + $this->assertEquals( 1, wc_notice_count( 'error' ) ); + + // multiple notices of different types + wc_add_notice( 'Bogus Notice 2', 'success' ); + wc_add_notice( 'Bogus Error Notice 2', 'error' ); + $this->assertEquals( 4, wc_notice_count() ); + } + + /** + * Test wc_has_notice() + * + * @since 2.2 + */ + function test_wc_has_notice() { + + // negative + wc_add_notice( 'Bogus Notice', 'success' ); + $this->assertFalse( wc_has_notice( 'Legit Notice' ) ); + + // positive + wc_add_notice( 'One True Notice', 'notice' ); + $this->assertTrue( wc_has_notice( 'One True Notice', 'notice' ) ); + } + + /** + * Test wc_notice_add_notice() + * + * @since 2.2 + */ + function test_wc_add_notice() { + + // default type + wc_add_notice( 'Test Notice' ); + $notices = wc_get_notices(); + $this->assertArrayHasKey( 'success', $notices ); + $this->assertEquals( 'Test Notice', $notices['success'][0] ); + + // clear notices + WC()->session->set( 'wc_notices', null ); + + // specific type + wc_add_notice( 'Test Error Notice', 'error' ); + $notices = wc_get_notices(); + $this->assertArrayHasKey( 'error', $notices ); + $this->assertEquals( 'Test Error Notice', $notices['error'][0] ); + } + + /** + * Test wc_clear_notices() + * + * @since 2.2 + */ + function test_wc_clear_notices() { + + wc_add_notice( 'Test Notice' ); + wc_clear_notices(); + $this->assertEmpty( WC()->session->get( 'wc_notices' ) ); + } + + /** + * Test wc_print_notices() + * + * @since 2.2 + */ + public function test_wc_print_notices() { + + wc_add_notice( 'One True Notice', 'notice' ); + + $this->expectOutputString( '
One True Notice
' ); + + wc_print_notices(); + + $this->assertEmpty( WC()->session->get( 'wc_notices' ) ); + } + + /** + * Test actions that print the notices + * + * @since 2.2 + */ + public function test_wc_print_notices_actions() { + + $this->assertNotFalse( has_action( 'woocommerce_before_shop_loop', 'wc_print_notices' ) ); + $this->assertNotFalse( has_action( 'woocommerce_before_single_product', 'wc_print_notices' ) ); + } + + /** + * Test wc_print_notice() w/ success type + * + * @since 2.2 + */ + public function test_wc_print_success_notice() { + + $this->expectOutputString( '
Success!
' ); + + wc_print_notice( 'Success!' ); + } + + /** + * Test wc_print_notice() w/ notice type + * + * @since 2.2 + */ + public function test_wc_print_info_notice() { + + $this->expectOutputString( '
Info!
' ); + + wc_print_notice( 'Info!', 'notice' ); + } + + /** + * Test wc_print_notice() w/ error type + * + * @since 2.2 + */ + public function test_wc_print_error_notice() { + + // specific type + $this->expectOutputString( '
  • Error!
' ); + + wc_print_notice( 'Error!', 'error' ); + } + + /** + * Test wc_get_notices() + * + * @since 2.2 + */ + public function test_wc_get_notices() { + + // no notices + $notices = wc_get_notices(); + $this->assertInternalType( 'array', $notices ); + $this->assertEmpty( $notices ); + + // default type + wc_add_notice( 'Another Notice' ); + $this->assertEquals( array( 'success' => array( 'Another Notice' ) ), wc_get_notices() ); + + // specific type + wc_add_notice( 'Error Notice', 'error' ); + $this->assertEquals( array( 'Error Notice' ), wc_get_notices( 'error' ) ); + + // invalid type + $notices = wc_get_notices( 'bogus_type' ); + $this->assertInternalType( 'array', $notices ); + $this->assertEmpty( $notices ); + } + +} diff --git a/tests/unit-tests/woocommerce.php b/tests/unit-tests/woocommerce.php index 5d2fc1f6bdf..a978f6c25c7 100644 --- a/tests/unit-tests/woocommerce.php +++ b/tests/unit-tests/woocommerce.php @@ -64,7 +64,7 @@ class WC_Tests_WooCommerce extends WC_Unit_Test_Case { $this->assertInstanceOf( 'WC_Product_Factory', $this->wc->product_factory ); $this->assertInstanceOf( 'WC_Order_Factory', $this->wc->order_factory ); $this->assertInstanceOf( 'WC_Countries', $this->wc->countries ); - $this->assertInstanceOf( 'WC_Session_Handler', $this->wc->session ); + $this->assertInstanceOf( 'WC_Mock_Session_Handler', $this->wc->session ); $this->assertInstanceOf( 'WC_Cart', $this->wc->cart ); $this->assertInstanceOf( 'WC_Customer', $this->wc->customer ); } diff --git a/woocommerce.php b/woocommerce.php index 8e7cf68f6d3..9a19912aef3 100644 --- a/woocommerce.php +++ b/woocommerce.php @@ -3,11 +3,11 @@ * Plugin Name: WooCommerce * Plugin URI: http://www.woothemes.com/woocommerce/ * Description: An e-commerce toolkit that helps you sell anything. Beautifully. - * Version: 2.2.0-bleeding + * Version: 2.2.0-RC1 * Author: WooThemes * Author URI: http://woothemes.com * Requires at least: 3.8 - * Tested up to: 3.9 + * Tested up to: 4.0 * * Text Domain: woocommerce * Domain Path: /i18n/languages/ @@ -510,7 +510,7 @@ final class WooCommerce { /** * Return the WC API URL for a given request * - * @param mixed $request + * @param string $request * @param mixed $ssl (default: null) * @return string */ @@ -597,7 +597,7 @@ final class WooCommerce { /** * Email Class. * - * @return WC_Email + * @return WC_Emails */ public function mailer() { return WC_Emails::instance();