Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Ninos Ego 2014-09-10 01:00:18 +02:00
commit 46b786c14f
87 changed files with 1474 additions and 466 deletions

3
.coveralls.yml Normal file
View File

@ -0,0 +1,3 @@
src_dir: .
coverage_clover: ./tmp/clover.xml
json_path: ./tmp/coveralls-upload.json

11
.scrutinizer.yml Normal file
View File

@ -0,0 +1,11 @@
filter:
excluded_paths:
- tests/*
- apigen/*
- includes/api/v1/*
- includes/libraries/*
checks:
php:
code_rating: true
duplication: true

View File

@ -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

View File

@ -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.

View File

@ -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 )
);

File diff suppressed because one or more lines are too long

View File

@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\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 <a href=\"%s\">reading the documentation</a>, for further assistance "
"you can use the <a href=\"%s\">community forum</a>, or if you have access "
"as a WooThemes customer, <a href=\"%s\">our support desk</a>."
"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. <a href=\"%s\">View Product</a>"
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. <a href=\"%s\">View Product</a>"
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. <a target=\"_blank\" href=\"%s\">Preview Product</a>"
msgstr ""
#: includes/admin/class-wc-admin-post-types.php:1638
#: includes/admin/class-wc-admin-post-types.php:1640
msgid ""
"Product scheduled for: <strong>%1$s</strong>. <a target=\"_blank\" "
"href=\"%2$s\">Preview Product</a>"
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. <a target=\"_blank\" href=\"%s\">Preview Product</a>"
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: <strong>%1$s</strong>."
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: <strong>%1$s</strong>."
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

View File

@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\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 "&nbsp;<small>%svia %s</small>"
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 &ndash; %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, <a href=\"%s\">read more...</a>"
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 &ndash; %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 ""

View File

@ -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() {

View File

@ -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() {

View File

@ -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
*/

View File

@ -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() {

View File

@ -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;

View File

@ -49,11 +49,11 @@ class WC_Admin_Help {
'title' => __( 'Support', 'woocommerce' ),
'content' =>
'<p>' . sprintf( __( 'After <a href="%s">reading the documentation</a>, for further assistance you can use the <a href="%s">community forum</a>, or if you have access as a WooThemes customer, <a href="%s">our support desk</a>.', 'woocommerce' ), 'http://docs.woothemes.com/documentation/plugins/woocommerce/', 'http://wordpress.org/support/plugin/woocommerce', 'http://support.woothemes.com' ) . '</p>' .
'<p>' . 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' ), '<a href="http://docs.woothemes.com/documentation/plugins/woocommerce/">', '</a>', '<a href="https://support.woothemes.com/hc/communities/public/topics">', '</a>', '<a href="http://support.woothemes.com">', '</a>' ) . '</p>' .
'<p>' . __( 'Before asking for help we recommend checking the status page to identify any problems with your configuration.', 'woocommerce' ) . '</p>' .
'<p><a href="' . admin_url('admin.php?page=wc-status') . '" class="button button-primary">' . __( 'System Status', 'woocommerce' ) . '</a> <a href="' . 'http://wordpress.org/support/plugin/woocommerce' . '" class="button">' . __( 'Community Support', 'woocommerce' ) . '</a> <a href="' . 'http://support.woothemes.com' . '" class="button">' . __( 'Customer Support', 'woocommerce' ) . '</a></p>'
'<p><a href="' . admin_url('admin.php?page=wc-status') . '" class="button button-primary">' . __( 'System Status', 'woocommerce' ) . '</a> <a href="' . 'https://support.woothemes.com/hc/communities/public/topics' . '" class="button">' . __( 'WooThemes Community Support', 'woocommerce' ) . '</a> <a href="' . 'http://support.woothemes.com' . '" class="button">' . __( 'WooThemes Customer Support', 'woocommerce' ) . '</a></p>'
) );

View File

@ -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 ) {

View File

@ -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 = '' ) {

View File

@ -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.

View File

@ -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: '')
*/

View File

@ -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 = '' ) {

View File

@ -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

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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/',
),
),
) );

View File

@ -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

View File

@ -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 ) {

View File

@ -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 ] ) )

View File

@ -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' );

View File

@ -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 ) {

View File

@ -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;

View File

@ -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' ) . ' <a href="' . esc_url( home_url() ) . '" class="wc-forward">' . __( 'Go to homepage', 'woocommerce' ) . '</a>', '', 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;

View File

@ -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 ) {

View File

@ -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 ) {

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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() {

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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);
}

View File

@ -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 ) {

View File

@ -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 );

View File

@ -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;

View File

@ -37,7 +37,7 @@ class Simplify_Chargeback extends Simplify_Object {
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> id</tt><tt> amount</tt><tt> description</tt><tt> dateCreated</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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
*/

View File

@ -81,7 +81,7 @@ class Simplify_Coupon extends Simplify_Object {
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> dateCreated</tt><tt> maxRedemptions</tt><tt> timesRedeemed</tt><tt> id</tt><tt> startDate</tt><tt> endDate</tt><tt> percentOff</tt><tt> couponCode</tt><tt> durationInMonths</tt><tt> amountOff</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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
*/

View File

@ -97,7 +97,7 @@ class Simplify_Customer extends Simplify_Object {
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> dateCreated</tt><tt> id</tt><tt> name</tt><tt> email</tt><tt> reference</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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
*/

View File

@ -37,7 +37,7 @@ class Simplify_Deposit extends Simplify_Object {
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> amount</tt><tt> dateCreated</tt><tt> depositDate</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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
*/

View File

@ -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);

View File

@ -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(

View File

@ -37,7 +37,7 @@ class Simplify_Invoice extends Simplify_Object {
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> id</tt><tt> invoiceDate</tt><tt> customer</tt><tt> amount</tt><tt> processedDate</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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
*/

View File

@ -77,7 +77,7 @@ class Simplify_InvoiceItem extends Simplify_Object {
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> id</tt><tt> amount</tt><tt> description</tt><tt> invoice</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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
*/

View File

@ -73,7 +73,7 @@ class Simplify_Payment extends Simplify_Object {
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> dateCreated</tt><tt> amount</tt><tt> id</tt><tt> description</tt><tt> paymentDate</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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
*/

View File

@ -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){

View File

@ -77,7 +77,7 @@ class Simplify_Plan extends Simplify_Object {
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> dateCreated</tt><tt> amount</tt><tt> frequency</tt><tt> name</tt><tt> id</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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
*/

View File

@ -60,7 +60,7 @@ class Simplify_Refund extends Simplify_Object {
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> id</tt><tt> amount</tt><tt> description</tt><tt> dateCreated</tt><tt> paymentDate</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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
*/

View File

@ -81,7 +81,7 @@ class Simplify_Subscription extends Simplify_Object {
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> id</tt><tt> plan</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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
*/

View File

@ -74,7 +74,7 @@ class Simplify_Webhook extends Simplify_Object {
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> dateCreated</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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
*/

View File

@ -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
*/

View File

@ -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.
*/

View File

@ -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 ) {

View File

@ -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' );

View File

@ -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
*/

View File

@ -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 = '' ) {

View File

@ -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 ) {

View File

@ -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() {

View File

@ -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
*/

View File

@ -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;

View File

@ -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
*/

View File

@ -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",

28
phpunit.xml.dist Normal file
View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="tests/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
verbose="true"
>
<testsuites>
<testsuite name="WooCommerce Test Suite">
<directory suffix=".php">./tests/unit-tests</directory>
</testsuite>
</testsuites>
<filter>
<blacklist>
<directory suffix=".php">./apigen/</directory>
<directory suffix=".php">./i18n/</directory>
<directory suffix=".php">./templates/</directory>
<directory suffix=".php">./tests/</directory>
<directory suffix=".php">./tmp/</directory>
</blacklist>
</filter>
<logging>
<log type="coverage-clover" target="./tmp/clover.xml" charset="UTF-8" />
</logging>
</phpunit>

View File

@ -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.

View File

@ -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-name> <db-user> <db-password> [db-host]
$ tests/bin/install.sh <db-name> <db-user> <db-password> [db-host]
Sample usage:
$ tests/install-wp-tests.sh woocommerce_tests root root
$ tests/bin/install.sh woocommerce_tests root root
**Important**: The `<db-name>` 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.

5
tests/install-wp-tests.sh → tests/bin/install.sh Normal file → Executable file
View File

@ -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() {

20
tests/bin/travis.sh Normal file
View File

@ -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

View File

@ -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' );
}

View File

@ -0,0 +1,7 @@
<?php
/**
* WooCommerce Mock Session Handler
*
* @since 2.2
*/
class WC_Mock_Session_Handler extends WC_Session { }

View File

@ -23,6 +23,37 @@ class WC_Unit_Test_Case extends WP_UnitTestCase {
// add custom factories
$this->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 );
}
}
}

View File

@ -0,0 +1,28 @@
<?php
/**
* WC Unit Test Factory
*
* Provides WooCommerce-specific factories
*
* @since 2.2
*/
class WC_Unit_Test_Factory extends WP_UnitTest_Factory {
/** @var \WC_Unit_Test_Factory_For_Webhook */
public $webhook;
/** @var \WC_Unit_Test_Factory_For_Webhook_Delivery */
public $webhook_delivery;
/**
* Setup factories
*/
public function __construct() {
parent::__construct();
$this->webhook = new WC_Unit_Test_Factory_For_Webhook( $this );
$this->webhook_delivery = new WC_Unit_Test_Factory_For_Webhook_Delivery( $this );
}
}

View File

@ -1,30 +1,8 @@
<?php
/**
* WC Unit Test Factory
*
* Provides WooCommerce-specific factories
*
* @since 2.2
*/
class WC_Unit_Test_Factory extends WP_UnitTest_Factory {
/** @var \WC_Unit_Test_Factory_For_Webhook_Delivery */
public $webhook_delivery;
/**
* Setup factories
*/
public function __construct() {
parent::__construct();
$this->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 {

View File

@ -0,0 +1,71 @@
<?php
/**
* Webhook Test Factory
*
* @see \WP_UnitTest_Factory_For_Post
* @since 2.2
*/
class WC_Unit_Test_Factory_For_Webhook extends WP_UnitTest_Factory_For_Post {
/**
* Setup factory
*
* @since 2.2
* @param null $factory
*/
public function __construct( $factory = null ) {
parent::__construct( $factory );
// set default
$this->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 );
}
}

View File

@ -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 ) );

View File

@ -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' ) );
}
/**

View File

@ -0,0 +1,37 @@
<?php
/**
* Test WC coupon functions
*
* @since 2.2
*/
class WC_Tests_Coupon_Functions extends WC_Unit_Test_Case {
/**
* Test wc_get_coupon_types()
*
* @since 2.2
*/
public function test_wc_get_coupon_types() {
$coupon_types = array(
'fixed_cart' => __( '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' ) );
}
}

View File

@ -0,0 +1,523 @@
<?php
/**
* Test WC formatting functions
*
* @since 2.2
*/
class WC_Tests_Formatting_Functions extends WC_Unit_Test_Case {
/**
* Test wc_sanitize_taxonomy_name()
*
* @since 2.2
*/
public function test_wc_sanitize_taxonomy_name() {
$this->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&nbsp;%2$s', get_woocommerce_price_format() );
// right space
update_option( 'woocommerce_currency_pos', 'right_space' );
$this->assertEquals( '%2$s&nbsp;%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( '<span class="amount">&pound;1.00</span>', wc_price( 1 ) );
$this->assertEquals( '<span class="amount">&pound;1.10</span>', wc_price( 1.1 ) );
$this->assertEquals( '<span class="amount">&pound;1.17</span>', wc_price( 1.17 ) );
$this->assertEquals( '<span class="amount">&pound;1,111.17</span>', wc_price( 1111.17 ) );
$this->assertEquals( '<span class="amount">&pound;0.00</span>', wc_price( 0 ) );
// different currency
$this->assertEquals( '<span class="amount">&#36;1,111.17</span>', wc_price( 1111.17, array( 'currency' => 'USD' ) ) );
// negative price
$this->assertEquals( '<span class="amount">-&pound;1.17</span>', wc_price( -1.17 ) );
// bogus prices
$this->assertEquals( '<span class="amount">&pound;0.00</span>', wc_price( null ) );
$this->assertEquals( '<span class="amount">&pound;0.00</span>', wc_price( 'Q' ) );
$this->assertEquals( '<span class="amount">&pound;0.00</span>', wc_price( 'ಠ_ಠ' ) );
// trim zeros
add_filter( 'woocommerce_price_trim_zeros', '__return_true' );
$this->assertEquals( '<span class="amount">&pound;1</span>', 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( '<span class="amount">&pound;1,111.17</span> <small>(ex. VAT)</small>', 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' ) );
}
}

View File

@ -0,0 +1,184 @@
<?php
/**
* Test WC notice functions
*
* @since 2.2
*/
class WC_Tests_Notice_Functions extends WC_Unit_Test_Case {
/**
* Clear out notices after each test
*
* @since 2.2
*/
public function tearDown() {
WC()->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( '<div class="woocommerce-info">One True Notice</div>' );
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( '<div class="woocommerce-message">Success!</div>' );
wc_print_notice( 'Success!' );
}
/**
* Test wc_print_notice() w/ notice type
*
* @since 2.2
*/
public function test_wc_print_info_notice() {
$this->expectOutputString( '<div class="woocommerce-info">Info!</div>' );
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( '<ul class="woocommerce-error"><li>Error!</li></ul>' );
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 );
}
}

View File

@ -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 );
}

View File

@ -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();