Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter hook to allow currently hardcoded 10 minute checkout draft stock reservation to be filtered #45246

Merged
merged 16 commits into from Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
7cb521e
Update Checkout.php
ninetyninew Mar 1, 2024
3757991
Add changefile(s) from automation for the following project(s): wooco…
invalid-email-address Mar 1, 2024
f58704c
Add filter hook for draft order stock hold (#45245)
ninetyninew Mar 1, 2024
950f8c9
Merge branch 'trunk' of https://github.com/ninetyninew/woocommerce in…
ninetyninew Mar 1, 2024
3a62305
Amending filter hook in changelog for draft order stock hold changes …
ninetyninew Mar 3, 2024
96e4fe8
Add changefile(s) from automation for the following project(s): wooco…
invalid-email-address Mar 3, 2024
a219a59
Add changefile(s) from automation for the following project(s): wooco…
invalid-email-address Mar 3, 2024
a4eab12
Add (int) to hook for draft order stock hold (#45245)
ninetyninew Mar 4, 2024
10c87ba
Fixing codesniff lint issues found on previous commits (#45245)
ninetyninew Mar 5, 2024
c361bfa
Adding negative check to draft order hold stock minutes (#45245)
ninetyninew Mar 6, 2024
9291ff0
Discarding older changes in favour of PR recommendations (#45245)
ninetyninew Mar 7, 2024
c131ab9
Add changefile(s) from automation for the following project(s): wooco…
invalid-email-address Mar 7, 2024
8df29af
Amends of woocommerce_order_hold_stock_minutes in favour of PR recomm…
ninetyninew Mar 9, 2024
35ba0bf
Add changefile(s) from automation for the following project(s): wooco…
invalid-email-address Mar 9, 2024
204180b
Amending woocommerce_order_hold_stock_minutes filter hook doc block c…
ninetyninew Mar 11, 2024
ed6c285
Merge branch 'trunk' of https://github.com/ninetyninew/woocommerce in…
ninetyninew Mar 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions plugins/woocommerce/changelog/45246-trunk
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Add `woocommerce_order_hold_stock_minutes` filter hook to allow the number of minutes stock in an order should be reserved for to be filtered.
11 changes: 11 additions & 0 deletions plugins/woocommerce/src/Checkout/Helpers/ReserveStock.php
@@ -1,4 +1,4 @@
<?php

Check notice on line 1 in plugins/woocommerce/src/Checkout/Helpers/ReserveStock.php

View workflow job for this annotation

GitHub Actions / Analyze Branch Changes

new filter found - woocommerce_order_hold_stock_minutes

\'woocommerce_order_hold_stock_minutes\' introduced in 8.8.0
/**
* Handle product stock reservation during checkout.
*/
Expand Down Expand Up @@ -67,6 +67,17 @@
*/
public function reserve_stock_for_order( $order, $minutes = 0 ) {
$minutes = $minutes ? $minutes : (int) get_option( 'woocommerce_hold_stock_minutes', 60 );
/**
* Filters the number of minutes an order should reserve stock for.
*
* This hook allows the number of minutes that stock in an order should be reserved for to be filtered, useful for third party developers to increase/reduce the number of minutes if the order meets certain criteria, or to exclude an order from stock reservation using a zero value.
*
* @since 8.8.0
*
* @param int $minutes How long to reserve stock for the order in minutes. Defaults to woocommerce_hold_stock_minutes or 10 if block checkout entry.
* @param \WC_Order $order Order object.
*/
$minutes = (int) apply_filters( 'woocommerce_order_hold_stock_minutes', $minutes, $order );

if ( ! $minutes || ! $this->is_enabled() ) {
return;
Expand Down