Code Monkey home page Code Monkey logo

woocommerce-sequential-order-numbers's Introduction

=== Sequential Order Numbers for WooCommerce ===
Contributors: SkyVerge, maxrice, tamarazuk, chasewiseman, nekojira, beka.rice
Tags: woocommerce, order number, sequential order number, woocommerce orders
Requires at least: 5.6
Tested up to: 6.3.1
Requires PHP: 7.4
Stable tag: 1.10.1

This plugin extends WooCommerce by setting sequential order numbers for new orders.

== Description ==

This plugin extends WooCommerce by automatically setting sequential order numbers for new orders.  If there are existing orders at the time of installation, the sequential order numbers will start with the highest current order number.

**This plugin requires WooCommerce 3.9.4 or newer.**

> No configuration needed! The plugin is so easy to use, there aren't even any settings. Activate it, and orders will automatically become sequential.

If you have no orders in your store, your orders will begin counting from order number 1. If you have existing orders, the count will pick up from your highest order number.

If you've placed test orders, you must trash **and** permanently delete them to begin ordering at "1" (trashed orders have to be counted in case they're restored, so they need to be gone completely).

= Support Details =

We do support our free plugins and extensions, but please understand that support for premium products takes priority. We typically check the forums every few days (usually with a maximum delay of one week).

= Sequential Order Numbers Pro =

If you like this plugin, but are looking for the ability to set the starting number, or to add a custom prefix/suffix to your order numbers (ie, you'd prefer something like WT101UK, WT102UK, etc) please consider our premium Sequential Order Numbers Pro for WooCommerce plugin, which is available in the [WooCommerce Store](http://woocommerce.com/products/sequential-order-numbers-pro/).

= More Details =
 - See the [product page](http://www.skyverge.com/product/woocommerce-sequential-order-numbers/) for full details.
 - Check out the [Pro Version](http://woocommerce.com/products/sequential-order-numbers-pro/).
 - View more of SkyVerge's [free WooCommerce extensions](http://profiles.wordpress.org/skyverge/)
 - View all [SkyVerge WooCommerce extensions](http://www.skyverge.com/shop/)

Interested in contributing? You can [find the project on GitHub](https://github.com/skyverge/woocommerce-sequential-order-numbers) and contributions are welcome :)

== Installation ==

You can install the plugin in a few ways:

1. Upload the entire 'woocommerce-sequential-order-numbers' folder to the '/wp-content/plugins/' directory
2. Upload the zip file you download via Plugins > Add New
3. Go to Plugins > Add New and search for "Sequential Order Numbers for WooCommerce", and install the one from SkyVerge.

Once you've installed the plugin, to get started please:

1. Activate the plugin through the "Plugins" menu in WordPress.
2. No configuration needed! Order numbers will continue sequentially from the current highest order number, or from 1 if no orders have been placed yet.

== Frequently Asked Questions ==

= Where are the settings? =

The plugin doesn't require any :) When you activate it, it gets to work right away! Orders will automatically become sequential, starting from the most recent order number.

= Why doesn't my payment gateway use this number? =

For full compatibility with extensions which alter the order number, such as Sequential Order Numbers, WooCommerce extensions should use `$order->get_order_number();` rather than `$order->id` when referencing the order number.

If your extension is not displaying the correct order number, you can try contacting the developers of your payment gateway to see if it's possible to make this tiny change. Using the order number instead is both compatible with WooCommerce core and our plugin, as without the order number being changed, it will be equal to the order ID.

= Can I start the order numbers at a particular number? =

This free version does not have that functionality, but the premium [Sequential Order Numbers Pro for WooCommerce](http://www.woothemes.com/products/sequential-order-numbers-pro/) will allow you to choose any starting number that's higher than your most current order number.

= Can I start the order numbers at "1"? =

If you want to begin numbering at "1", you must trash, then permanently delete all orders in your store so that there are no order numbers already being counted.

= Can I set an order number prefix/suffix? =

This free version does not have that functionality, but it's included in the premium [Sequential Order Numbers Pro for WooCommerce](http://www.woothemes.com/products/sequential-order-numbers-pro/).

== Other Notes ==

If you'd like to make your payment gateway compatible with Sequential Order Numbers, or other plugins that filter the order number, please make one small change. Instead of referencing `$order->id` when storing order data, reference: `$order->get_order_number()`

This is compatible with WooCommerce core by default, as the order number is typically equal to the order ID. However, this will also let you be compatible with plugins such as ours, as the order number can be filtered (which is what we do to make it sequential), so using order number is preferred.

Some other notes to help developers:

= Get an order from order number =

If you want to access the order based on the sequential order number, you can do so with a helper method:

`
$order_id = wc_sequential_order_numbers()->find_order_by_order_number( $order_number );
`

This will give you the order's ID (post ID), and you can get the order object from this.

= Get the order number =

If you have access to the order ID or order object, you can easily get the sequential order number based on WooCommerce core functions.

`
$order = wc_get_order( $order_id );
$order_number = $order->get_order_number();
`

== Changelog ==

- 2023.09.05 - version 1.10.1 =
 * Fix - Call save order method only in HPOS installs to avoid setting the same order number meta twice in CPT installations

- 2023.08.02 - version 1.10.0 =
 * Tweak - Also set sequential order numbers for orders sent via the WooCommerce Checkout Block
 * Misc - Add compatibility for WooCommerce High Performance Order Storage (HPOS)
 * Misc - Require PHP 7.4 and WordPress 5.6

= 2022.07.30 - version 1.9.7 =
 * Misc - Rename to Sequential Order Numbers for WooCommerce

= 2022.03.01 - version 1.9.6 =
 * Misc - Require WooCommerce 3.9.4 or newer
 * Misc - Replace calls to deprecated `is_ajax()` with `wp_doing_ajax()`

= 2020.05.07 - version 1.9.5 =
 * Misc - Add support for WooCommerce 4.1

= 2020.03.10 - version 1.9.4 =
 * Misc - Add support for WooCommerce 4.0

= 2020.02.05 - version 1.9.3 =
 * Misc - Add support for WooCommerce 3.9

= 2019.11.05 - version 1.9.2 =
 * Misc - Add support for WooCommerce 3.8

= 2019.10.03 - version 1.9.1 =
 * Fix - Fix order number filter in WooCommerce Admin Downloads Analytics

= 2019.08.15 - version 1.9.0 =
* Misc - Add support for WooCommerce 3.7
* Misc - Remove support for WooCommerce 2.6

= 2018.07.17 - version 1.8.3 =
* Misc - Require WooCommerce 2.6.14+ and WordPress 4.4+

= 1.8.2 - 2017.08.22 =
* Fix - PHP deprecation warning when Subscriptions is used
* Misc - Removed support for WooCommerce Subscriptions older than v2.0

= 1.8.1 - 2017.03.28 =
* Fix - Removes errors on refund number display

= 1.8.0 - 2017.03.23 =
* Fix - Admin orderby was not properly scoped to orders, props [@brandondove](https://github.com/brandondove)
* Misc - Added support for WooCommerce 3.0
* Misc - Removed support for WooCommerce 2.4

= 1.7.0 - 2016.05.24 =
* Misc - Added support for WooCommerce 2.6
* Misc - Removed support for WooCommerce 2.3

= 1.6.1 - 2016.02.04 =
* Misc - WooCommerce Subscriptions: Use new hook wcs_renewal_order_meta_query instead of deprecated woocommerce_subscriptions_renewal_order_meta_query

= 1.6.0 - 2016.01.20 =
* Misc - WooCommerce Subscriptions: Use new filter hook wcs_renewal_order_created instead of deprecated woocommerce_subscriptions_renewal_order_created
* Misc - WooCommerce 2.5 compatibility
* Misc - Dropped WooCommerce 2.2 support

= 1.5.1 - 2015.11.26 =
* Fix - Compatibility fix with WooCommerce Subscriptions 2.0

= 1.5.0 - 2015.07.28 =
* Misc - WooCommerce 2.4 Compatibility

= 1.4.0 - 2015.02.10 =
* Fix - Improved install routine for shops with a large number of orders
* Misc - WooCommerce 2.3 compatibility

= 1.3.4 - 2014.09.23 =
* Fix - Compatibility fix with WooCommerce 2.1
* Fix - Fix a deprecated notice in WooCommerce 2.2

= 1.3.3 - 2014.09.05 =
* Localization - Included a .pot file for localization

= 1.3.2 - 2014.09.02 =
* Misc - WooCommerce 2.2 compatibility

= 1.3.1 - 2014.01.22 =
* Misc - WooCommerce 2.1 compatibility

= 1.3 - 2013.04.26 =
* Feature - Improved WooCommerce Subscriptions compatibility
* Feature - Improved WooCommerce Pre-Orders compatibility
* General code cleanup and refactor

= 1.2.4 - 2012.12.14 =
* Fix - WordPress 3.5 compatibility fix
* Fix - Order numbers not assigned to temporary auto-draft orders created from the admin

= 1.2.3 - 2012.06.06 =
* Fix - Removed WooCommerce functions, which caused a compatibility issue with other WooCommerce plugins

= 1.2.2 - 2012.05.25 =
* Tweak - Takes advantage of new action hooks/filters available in WooCommerce 1.5.6
* Fix - Bug fix on installation to stores with more than 10 existing orders

= 1.2.1 - 2012.05.13 =
* Tweak - Minor updates due to WooCommerce 1.5.5 release

= 1.2.0 - 2012.04.21 =
* Feature - Added support for the order tracking page

= 1.1.2 - 2012.04.18 =
* Tweak - Minor updates due to WooCommerce 1.5.4 release

= 1.1.1 - 2012.04.02 =
* Fix - Order number in the subject line of the admin new order email is fixed

= 1.1.0 - 2012.04.02 =
* Feature - Search by order number

= 1.0.1 - 2012.04.02 =
* Fix - small bug fix

= 1.0.0 - 2012.04.02 =
* Initial Release

== Upgrade Notice ==

= 1.2.2 - 2012.05.25 =
This version requires WooCommerce 1.5.6

= 1.2.1 - 2012.05.13 =
This version requires WooCommerce 1.5.5

woocommerce-sequential-order-numbers's People

Contributors

adrianocastro189 avatar bekarice avatar chasewiseman avatar deivamagalhaes avatar hsingyuc avatar itambek-godaddy avatar jdeeburke avatar jeffstieler avatar jstern-godaddy avatar lgfogle avatar ssmith1-godaddy avatar tamarazuk avatar unfulvio avatar unfulvio-godaddy avatar wvega avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

woocommerce-sequential-order-numbers's Issues

Save order method called for non HPOS installations

After recent merge of #33 and update on our site, one of the 3rd party plugins started inserting its meta twice instead of just once. Xdebug led me to this line:

// with HPOS we need to trigger a save to update the order number or it won't persist by using the direct query above alone
$order->save();

Comment says save() should be triggered for HPOS installations but there's no condition checking it. Once I added it, double meta is no longer a problem.

// with HPOS we need to trigger a save to update the order number or it won't persist by using the direct query above alone
if ( $using_hpos ) {
    $order->save();
}

@unfulvio-godaddy could you verify?

cc @lkraav

1.10.1: finding next sequential order number super-slow (15 min) on postmeta model with high row count

INSERT INTO wp_postmeta (post_id, meta_key, meta_value) SELECT 8705342, '_order_number', IF( MAX( CAST( meta_value as UNSIGNED ) ) IS NULL, 1, MAX( CAST( meta_value as UNSIGNED ) ) + 1 ) FROM wp_postmeta WHERE meta_key='_order_number'

This query is currently taking 15 minutes to execute on our live server, with millions of posts, few tens of millions of postmeta rows.
What can we do to improve this query on postmeta, other than HPOS migration (it's roadmapped, but not immediate)?

EXPLAIN below:

EXPLAIN PARTITIONS
select 8705342, '_order_number', IF( MAX( CAST( meta_value as UNSIGNED ) ) IS NULL, 1, MAX( CAST( meta_value as UNSIGNED ) ) + 1 ) FROM wp_postmeta WHERE meta_key='_order_number'
___________ Sub-Part 1 ___________
Select Type: SIMPLE               
      Table: wp_postmeta          
 Partitions:                      
       Type: ref                  
 Poss. Keys: meta_key             
      Index: meta_key             
 Key Length: 1022                 
  Index Ref: const                
  Row Count: 196706               
    Special: Using index condition

[This query has been re-written to be explainable]

x

x

Woocommerce bookings?

It partially doesnt work with the WooCommerce Bookings plugin if i try to create a booking and assign it to order number, it throws this error: 'Invalid order ID provided'

assign-code

make wc-json api compatible

I'd like to make the v2/orders/:id endpoint work with the sequential order number. Now it only accepts the actual order ID, is there a way to make it recognize the order_number as well?

get_order_meta() arg 1 defined as WC_Order

Hello,

I'm using the WooCommerce Sequential Order Numbers latest version with WooCommerce PDF Invoices & Packing Slips and WooCommerce PDF Invoices & Packing Slips Professional versions 1.6.0 and 1.5.0 respectively, and I'm experience the following fatal error when I try to generate a Credit Note PDF:

[28-Mar-2017 10:44:03 UTC] PHP Catchable fatal error: Argument 1 passed to WC_Seq_Order_Number::get_order_meta() must be an instance of WC_Order, instance of WC_Order_Refund given, called in /var/www/html/tlc-preprod/wp-content/plugins/woocommerce-sequential-order-numbers/woocommerce-sequential-order-numbers.php on line 232 and defined in /var/www/html/tlc-preprod/wp-content/plugins/woocommerce-sequential-order-numbers/woocommerce-sequential-order-numbers.php on line 440

In previous version of the WooCommerce PDF Invoices & Packing Slips, this issue can't be reproduced. However, IMHO I believe the issue is an oversight in your implementation.

The method get_order_meta() expect arg 1 to be an instance of WC_Order.
However, this arg is the second arg passed to the woocommerce_order_number filter. The filter is defined in WC_Abstract_Order class, and WC_Order and WC_Order_Refund both extend this class. IMO you could expect both instance types to be passed to the filter. Would you agree?

Thanks,
A

Exclude 'checkout-draft' order status

The new WooCommerce Blocks checkout a draft order is created when customers visit the checkout. These orders have the status of 'checkout-draft'. These can mess up number order.

Could it be possible to exclude these orders as well? The 'checkout-draft orders' have a high chance of being abandoned and automatically deleted. There is no need to number them until they become a real order.

FYI Deprecated hook

Hi Guys,

Just an FYI I'm a seeing the following

[02-Feb-2016 12:38:20 UTC] PHP Notice:  The "woocommerce_subscriptions_renewal_order_meta_query" hook uses out of date data structures so is <strong>deprecated</strong> since version 2.0 of WooCommerce Subscriptions! Use wcs_renewal_order_meta_query instead. in /var/www/gimme/ticket-378883-SON/wp-includes/functions.php on line 3573

Looks like woocommerce_subscriptions_renewal_order_meta_query() is used here

We use wcs_renewal_order_meta_query here

Cheers.

Compatibility issue with WooCommerce Subscriptions 2.0.x

WC 2.7 Compatibility

  • Misc -- Drop support for WooCommerce < 2.5

    • Replace any paid status checks with $order->is_paid()
  • Misc -- Add support for WooCommerce 2.7

    • Add compat methods to get orders and favor accessors instead of directly using order properties
  • Misc -- Update tested up to / requires versions

  • Misc -- Update readme + changelog

  • Investigate -- Check this issue, if possible: #11

Compatibility FAQ

@bekarice Could we add an FAQ to the readme explaining why some extensions like gateways may not display the sequential order number?

As usual, massage the below text to your heart's content ๐Ÿ˜บ . Thanks!


For full compatibility with extensions which alter the order number, such as Sequential Order Numbers, WooCommerce extensions should use $order->get_order_number() rather than $order->id when referencing the order number. If your extension is not displaying the correct order number, you can try contacting the developers of your payment gateway to see if it's possible to make this tiny change.

1.9.7: Deprecated: Hook wcs_renewal_order_meta_query is <strong>deprecated</strong> since version subscriptions-core 2.5.0! Use wc_subscriptions_renewal_order_data instead.

(PS https://github.com/godaddy-wordpress/woocommerce-sequential-order-numbers/releases is missing 1.9.7)

Deprecated: Hook wcs_renewal_order_meta_query is <strong>deprecated</strong> since version subscriptions-core 2.5.0! Use wc_subscriptions_renewal_order_data instead.
Deprecated: Hook wcs_renewal_order_meta is <strong>deprecated</strong> since version wcs-core 2.5.0! Use wc_subscriptions_renewal_order_data instead

This plugin is one of the few remaining that haven't received an update to recent https://github.com/Automattic/woocommerce-subscriptions-core hooks changes.

add_filter( 'wcs_renewal_order_meta_query', array( $this, 'subscriptions_remove_renewal_order_meta' ) );

@unfulvio-godaddy wdyt can yall push a patch out?

WooCommerce v2.6 Compatibility

tacking changes slated for v2.6 compatibility updates

General Changes

  • convert to singleton pattern
  • update readme sample code snippet to reflect the change to singleton

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.