(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[3],{177:function(e,t,n){"use strict";n.d(t,"b",(function(){return y})),n.d(t,"a",(function(){return E}));var c=n(4),r=n.n(c),o=n(13),i=n.n(o),a=n(0),s=(n(2),n(21)),u=n(85),f=n(75),l=n(10),d=n.n(l),b=n(7),v=n.n(b),O=n(936),p=(n(224),function(e){var t=e.status;switch(void 0===t?"default":t){case"error":return"woocommerce-error";case"success":return"woocommerce-success";case"info":case"warning":return"woocommerce-info"}return""}),m=function(e){var t=e.className,n=e.notices,c=e.removeNotice,r=n.filter((function(e){return"snackbar"!==e.type}));if(!r.length)return null;var o=v()(t,"wc-block-components-notices");return Object(a.createElement)("div",{className:o},r.map((function(e){return Object(a.createElement)(O.a,d()({key:"store-notice-"+e.id},e,{className:v()("wc-block-components-notices__notice","woocommerce-message",p(e)),onRemove:function(){e.isDismissible&&c(e.id)}}),e.content)})))},j=n(941),g=function(e){var t=e.className,n=e.notices,c=e.removeNotice;if(e.isEditor)return null;var r=n.filter((function(e){return"snackbar"===e.type})),o=v()(t,"wc-block-components-notices__snackbar");return Object(a.createElement)(j.a,{notices:r,className:o,onRemove:c})};function N(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);t&&(c=c.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,c)}return n}function h(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};v(e,t,h(h({},n),{},{context:n.context||d})),E("store-notice-create",{status:e,content:t,options:n})}),[v,E,d]),P=Object(a.useCallback)((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d;O(e,t)}),[O,d]),D=Object(a.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};S("default",e,h(h({},t),{},{type:"snackbar"}))}),[S]),C={notices:Object(s.useSelect)((function(e){return{notices:e("core/notices").getNotices(d)}}),[d]).notices,createNotice:S,createSnackbarNotice:D,removeNotice:P,context:d,setIsSuppressed:y},I=N?null:Object(a.createElement)(m,{className:c,notices:C.notices,removeNotice:C.removeNotice,isEditor:k}),x=N?null:Object(a.createElement)(g,{notices:C.notices,removeNotice:C.removeNotice,isEditor:k});return Object(a.createElement)(w.Provider,{value:C},o&&I,t,x)}},224:function(e,t){},62:function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var c=n(4),r=n.n(c),o=n(0),i=n(177);function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);t&&(c=c.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,c)}return n}function s(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:null;u.current.forEach((function(t){null!==e&&t.status!==e||c(t.id)}))},removeNotice:c}}),[c]),l=Object(o.useMemo)((function(){return{addDefaultNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n("default",e,s({},t))},addErrorNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n("error",e,s({},t))},addWarningNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n("warning",e,s({},t))},addInfoNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n("info",e,s({},t))},addSuccessNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n("success",e,s({},t))},addSnackbarNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r(e,t)}}}),[n,r]);return s(s(s({notices:t},f),l),{},{setIsSuppressed:a})}},846:function(e,t,n){"use strict";n.d(t,"a",(function(){return d}));var c=n(13),r=n.n(c),o=n(0),i=n(21),a=n(36),s=n(26),u=n(51),f=n(62),l=function(e,t){var n=e.find((function(e){return e.id===t}));return n?n.quantity:0},d=function(e){var t=Object(i.useDispatch)(a.CART_STORE_KEY).addItemToCart,n=Object(u.a)(),c=n.cartItems,d=n.cartIsLoading,b=Object(f.a)(),v=b.addErrorNotice,O=b.removeNotice,p=Object(o.useState)(!1),m=r()(p,2),j=m[0],g=m[1],N=Object(o.useRef)(l(c,e));return Object(o.useEffect)((function(){var t=l(c,e);t!==N.current&&(N.current=t)}),[c,e]),{cartQuantity:Number.isFinite(N.current)?N.current:0,addingToCart:j,cartIsLoading:d,addToCart:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return g(!0),t(e,n).then((function(){O("add-to-cart")})).catch((function(e){v(Object(s.decodeEntities)(e.message),{context:"wc/all-products",id:"add-to-cart",isDismissible:!0})})).finally((function(){g(!1)}))}}}}}]);#services-config{float:right;min-width:700px;width:100%}#services-config h3{color:#464646;font-size:15px;font-weight:400;margin:0;overflow:hidden;padding:8px 10px;white-space:nowrap}#available-services,#enabled-services,#live-preview{border-spacing:0;padding:20px 0 0;width:100%}#enabled-services .ui-sortable{min-height:50px}#enabled-services{padding-bottom:20px}#available-services,#enabled-services{border-bottom:2px solid #ccc}#live-preview{border-bottom:1px solid #dcdcde;padding-bottom:60px}#available-services h3,#enabled-services h3,#live-preview h3{margin-bottom:1em;margin-top:0;padding:0}body.settings_page_sharing .description{vertical-align:top;width:180px}body.settings_page_sharing .description p{font-size:13px;font-style:italic}body.settings_page_sharing .services{padding:0 20px;vertical-align:top}body.settings_page_sharing .services ul li{cursor:move}body.settings_page_sharing .services ul li.divider{background:none;border:none;cursor:default;padding:0}body.settings_page_sharing ul.services-hidden{margin-bottom:0}#available-services .service,#enabled-services .service{background:#fff;border-radius:4px;box-shadow:0 1px 2px #0000001f,0 0 0 1px #0000001f;color:#2c3338!important;display:inline-block;font-family:Open Sans,sans-serif;font-size:13px;font-weight:500;line-height:23px;margin:0 0 8px 8px;padding:3px 9px 4px 11px}#available-services .service .options-left,#enabled-services .service .options-left{align-items:center;display:flex}#available-services .service:hover,#enabled-services .service:hover{box-shadow:0 1px 2px #00000038,0 0 0 1px #00000038}#available-services .service.share-deprecated,#enabled-services .service.share-deprecated{opacity:.5;padding:5px;text-decoration:line-through}#available-services .service.share-deprecated{display:none}li.service span:before{-webkit-font-smoothing:antialiased;font:400 18px/1 social-logos;height:16px;margin-left:6px;position:relative;top:-1px;width:16px}li.service.share-print span:before{content:"\f469"}li.service.share-digg span:before{content:"\f221"}li.service.share-email span:before{content:"\f410"}li.service.share-linkedin span:before{content:"\f207"}li.service.share-twitter span:before,li.service.share-x span:before{content:"\f10e"}li.service.share-reddit span:before{content:"\f222"}li.service.share-tumblr span:before{content:"\f214"}li.service.share-pocket span:before{content:"\f224"}li.service.share-pinterest span:before{content:"\f209"}li.service.share-facebook span:before{content:"\f203"}li.service.share-press-this span:before{content:"\f205"}li.service.share-telegram span:before{content:"\f606"}li.service.share-threads span:before{content:"\f10d"}li.service.share-jetpack-whatsapp span:before{content:"\f608"}li.service.share-mastodon span:before{content:"\f10a"}li.service.share-nextdoor span:before{content:"\f10c"}li.service.share-bluesky span:before{content:"\f10f"}body.settings_page_sharing ul.preview{display:flex;flex-wrap:wrap;float:right}body.settings_page_sharing ul.preview li.preview-item,body.settings_page_sharing ul.preview li.preview-item a{cursor:default;text-decoration:none}div.sd-social-icon .inner li.preview-item a span,div.sd-social-icon ul.preview li.preview-item a span{display:none}div.sd-social-icon ul.preview li.preview-item.preview-custom a span{display:inline-block}.services .preview li.share-custom a{text-decoration:none}.services ul li.end-fix{clear:both;float:none;height:20px;margin:0;padding:0;visibility:hidden;width:0}#enabled-services h2{color:#999;font-size:20px;font-weight:400!important;padding-top:0}body.settings_page_sharing #live-preview h2{color:#e3e3e3;font-size:20px;font-weight:400!important}body.settings_page_sharing .clearing{clear:both}body.settings_page_sharing .options .options-left{float:right}body.settings_page_sharing .input label{font-size:11px;line-height:16px}body.settings_page_sharing .advanced-form{border-top:1px solid #e3e3e3;display:none;margin-right:-24px;margin-top:4px;padding:10px 10px 8px 14px}body.settings_page_sharing .utility{float:left;font-size:10px;padding-left:10px;padding-top:10px}body.settings_page_sharing .advanced input[type=submit]{float:right;margin-left:10px;margin-top:10px}.services li.dropzone{background:#e3e3e3;border:1px dashed #999;border-radius:3px;height:18px;margin-left:10px;padding:5px}.advanced-form .form-table th{width:auto!important}.advanced-form .button-secondary{margin-top:0!important}#hidden-drop-target{background:#e1e1e1;border:1px solid #cdcdcd;padding:10px;vertical-align:top;width:29%}#hidden-drop-target p{font-size:13px;font-style:italic;margin:0 0 10px}.preview li.preview-item{background-position:100% 5px;cursor:default}.preview .option-smart-on{margin:3px 0 0 5px}.preview-digg .option-smart-on{background:url(../../modules/sharedaddy/images/smart-digg.png) no-repeat 100% 0;background-size:76px 17px;height:17px;margin-top:2px;width:76px}.preview-facebook .option-smart-on{background:url(../../modules/sharedaddy/images/smart-like.png) no-repeat 100% 0;background-size:85px 20px;height:20px;margin-right:-4px;width:85px}.preview-twitter .option-smart-on,.preview-x .option-smart-on{background:url(../../modules/sharedaddy/images/smart-x.png) no-repeat 100% 0;background-size:60px 20px;height:20px;width:60px}.preview-linkedin .option-smart-on{background:url(../../modules/sharedaddy/images/linkedin-smart.png) no-repeat top;background-size:99px 18px;height:20px;width:99px}.preview-tumblr .option-smart-on{background:url(../../modules/sharedaddy/images/smart-tumblr.png) no-repeat 100% 0;background-size:62px 20px;height:20px;width:62px}.preview-pinterest .option-smart-on{background:url(../../modules/sharedaddy/images/smart-pinterest.png) no-repeat 100% 0;background-size:39px 20px;height:20px;width:39px}.preview-pocket .option-smart-on{background:url(../../modules/sharedaddy/images/smart-pocket.png) no-repeat 100% 0;background-size:60px 20px;height:20px;width:60px}.preview-item.share-deprecated{opacity:.5}.preview-item.share-deprecated a span{text-decoration:line-through}@media (min-resolution:120dpi){.preview-digg .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-digg@2x.png)}.preview-facebook .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-like@2x.png)}.preview-twitter .option-smart-on,.preview-x .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-x@2x.png)}.preview-linkedin .option-smart-on{background-image:url(../../modules/sharedaddy/images/linkedin-smart@2x.png)}.preview-tumblr .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-tumblr@2x.png)}.preview-pinterest .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-pinterest@2x.png)}.preview-pocket .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-pocket@2x.png)}}.services .sharing-hidden li{background-color:initial}.sharing-hidden li.share-end{clear:both;float:none;height:0;margin:0!important;padding:0!important;visibility:hidden;width:0}.preview .sharing-label{border:0;font-weight:700;padding:4px 0 0 6px}#services-config a.remove{background:#dcdcde;border-radius:15px;color:#fff;font-size:10px;font-weight:700;padding:0 4px 2px;text-decoration:none}#services-config a.remove:hover{background:red}.sd-social-icon .inner a.sd-button span,.sd-social-icon .inner a.share-icon span{display:inline-block;overflow:hidden;text-indent:100%;width:0}.sharing-block-message__items-wrapper{column-gap:6rem;display:flex;flex-wrap:wrap}.sharing-block-message__buttons-wrapper .button{margin-left:1rem}.sharing-block-message__buttons-wrapper .button-primary:visited{color:#fff}.admin-sharing-settings__block-theme-description{font-style:italic;margin-top:1rem}a.dops-card__link{cursor:pointer}.settings-sharing__block-theme-description{font-style:italic}export { default as Sidebar } from './sidebar'; export { default as Main } from './main'; export { default as SidebarLayout } from './sidebar-layout'; /** * External dependencies */ import { __ } from '@wordpress/i18n'; import PropTypes from 'prop-types'; import { getSetting } from '@woocommerce/settings'; import LoadMoreButton from '@woocommerce/base-components/load-more-button'; import { ReviewList, ReviewSortSelect, } from '@woocommerce/base-components/reviews'; import withReviews from '@woocommerce/base-hocs/with-reviews'; /** * Block rendered in the frontend. * * @param {Object} props Incoming props for the component. * @param {Object} props.attributes Incoming block attributes. * @param {function(any):any} props.onAppendReviews Function called when appending review. * @param {function(any):any} props.onChangeOrderby * @param {Array} props.reviews * @param {string} props.sortSelectValue * @param {number} props.totalReviews */ const FrontendBlock = ( { attributes, onAppendReviews, onChangeOrderby, reviews, sortSelectValue, totalReviews, } ) => { if ( reviews.length === 0 ) { return null; } const reviewRatingsEnabled = getSetting( 'reviewRatingsEnabled', true ); return ( <> { attributes.showOrderby !== 'false' && reviewRatingsEnabled && ( ) } { attributes.showLoadMore !== 'false' && totalReviews > reviews.length && ( ) } ); }; FrontendBlock.propTypes = { /** * The attributes for this block. */ attributes: PropTypes.object.isRequired, onAppendReviews: PropTypes.func, onChangeArgs: PropTypes.func, // from withReviewsattributes reviews: PropTypes.array, totalReviews: PropTypes.number, }; export default withReviews( FrontendBlock ); /** * WooCommerce Order Functions * * Functions for order specific things. * * @package WooCommerce\Functions * @version 3.4.0 */ use Automattic\WooCommerce\Caches\OrderCountCache; use Automattic\WooCommerce\Enums\OrderStatus; use Automattic\WooCommerce\Enums\OrderInternalStatus; use Automattic\WooCommerce\Internal\CostOfGoodsSold\CostOfGoodsSoldController; use Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer; use Automattic\WooCommerce\Internal\Utilities\Users; use Automattic\WooCommerce\Utilities\OrderUtil; use Automattic\WooCommerce\Utilities\StringUtil; defined( 'ABSPATH' ) || exit; /** * Standard way of retrieving orders based on certain parameters. * * This function should be used for order retrieval so that when we move to * custom tables, functions still work. * * Args and usage: https://github.com/woocommerce/woocommerce/wiki/wc_get_orders-and-WC_Order_Query * * @since 2.6.0 * @param array $args Array of args (above). * @return WC_Order[]|stdClass Number of pages and an array of order objects if * paginate is true, or just an array of values. */ function wc_get_orders( $args ) { $map_legacy = array( 'numberposts' => 'limit', 'post_type' => 'type', 'post_status' => 'status', 'post_parent' => 'parent', 'author' => 'customer', 'email' => 'billing_email', 'posts_per_page' => 'limit', 'paged' => 'page', ); foreach ( $map_legacy as $from => $to ) { if ( isset( $args[ $from ] ) ) { $args[ $to ] = $args[ $from ]; } } // Map legacy date args to modern date args. $date_before = false; $date_after = false; if ( ! empty( $args['date_before'] ) ) { $datetime = wc_string_to_datetime( $args['date_before'] ); $date_before = strpos( $args['date_before'], ':' ) ? $datetime->getOffsetTimestamp() : $datetime->date( 'Y-m-d' ); } if ( ! empty( $args['date_after'] ) ) { $datetime = wc_string_to_datetime( $args['date_after'] ); $date_after = strpos( $args['date_after'], ':' ) ? $datetime->getOffsetTimestamp() : $datetime->date( 'Y-m-d' ); } if ( $date_before && $date_after ) { $args['date_created'] = $date_after . '...' . $date_before; } elseif ( $date_before ) { $args['date_created'] = '<' . $date_before; } elseif ( $date_after ) { $args['date_created'] = '>' . $date_after; } $query = new WC_Order_Query( $args ); return $query->get_orders(); } /** * Main function for returning orders, uses the WC_Order_Factory class. * * @since 2.2 * * @param mixed $the_order Post object or post ID of the order. * * @return bool|WC_Order|WC_Order_Refund */ function wc_get_order( $the_order = false ) { if ( ! did_action( 'woocommerce_after_register_post_type' ) ) { wc_doing_it_wrong( __FUNCTION__, 'wc_get_order should not be called before post types are registered (woocommerce_after_register_post_type action)', '2.5' ); return false; } return WC()->order_factory->get_order( $the_order ); } /** * Get all order statuses. * * @since 2.2 * @used-by WC_Order::set_status * @return array */ function wc_get_order_statuses() { $order_statuses = array( OrderInternalStatus::PENDING => _x( 'Pending payment', 'Order status', 'woocommerce' ), OrderInternalStatus::PROCESSING => _x( 'Processing', 'Order status', 'woocommerce' ), OrderInternalStatus::ON_HOLD => _x( 'On hold', 'Order status', 'woocommerce' ), OrderInternalStatus::COMPLETED => _x( 'Completed', 'Order status', 'woocommerce' ), OrderInternalStatus::CANCELLED => _x( 'Cancelled', 'Order status', 'woocommerce' ), OrderInternalStatus::REFUNDED => _x( 'Refunded', 'Order status', 'woocommerce' ), OrderInternalStatus::FAILED => _x( 'Failed', 'Order status', 'woocommerce' ), ); return apply_filters( 'wc_order_statuses', $order_statuses ); } /** * See if a string is an order status. * * @param string $maybe_status Status, including any wc- prefix. * @return bool */ function wc_is_order_status( $maybe_status ) { $order_statuses = wc_get_order_statuses(); return isset( $order_statuses[ $maybe_status ] ); } /** * Get list of statuses which are consider 'paid'. * * @since 3.0.0 * @return array */ function wc_get_is_paid_statuses() { /** * Filter the list of statuses which are considered 'paid'. * * @since 3.0.0 * * @param array $statuses List of statuses. */ return apply_filters( 'woocommerce_order_is_paid_statuses', array( OrderStatus::PROCESSING, OrderStatus::COMPLETED ) ); } /** * Get list of statuses which are consider 'pending payment'. * * @since 3.6.0 * @return array */ function wc_get_is_pending_statuses() { /** * Filter the list of statuses which are considered 'pending payment'. * * @since 3.6.0 * * @param array $statuses List of statuses. */ return apply_filters( 'woocommerce_order_is_pending_statuses', array( OrderStatus::PENDING ) ); } /** * Get the nice name for an order status. * * @since 2.2 * @param string $status Status. * @return string */ function wc_get_order_status_name( $status ) { // "Special statuses": these are in common usage across WooCommerce, but are not normally returned by // wc_get_order_statuses(). $special_statuses = array( 'wc-' . OrderStatus::AUTO_DRAFT => OrderStatus::AUTO_DRAFT, 'wc-' . OrderStatus::TRASH => OrderStatus::TRASH, ); // Merge order is important. If the special statuses are ever returned by wc_get_order_statuses(), those definitions // should take priority. $statuses = array_merge( $special_statuses, wc_get_order_statuses() ); $unprefixed = OrderUtil::remove_status_prefix( (string) $status ); if ( ! is_string( $status ) ) { wc_doing_it_wrong( __FUNCTION__, __( 'An invalid order status slug was supplied.', 'woocommerce' ), '9.6' ); } return $statuses[ 'wc-' . $unprefixed ] ?? $unprefixed; } /** * Generate an order key with prefix. * * @since 3.5.4 * @param string $key Order key without a prefix. By default generates a 13 digit secret. * @return string The order key. */ function wc_generate_order_key( $key = '' ) { if ( '' === $key ) { $key = wp_generate_password( 13, false ); } return 'wc_' . apply_filters( 'woocommerce_generate_order_key', 'order_' . $key ); } /** * Finds an Order ID based on an order key. * * @param string $order_key An order key has generated by. * @return int The ID of an order, or 0 if the order could not be found. */ function wc_get_order_id_by_order_key( $order_key ) { $data_store = WC_Data_Store::load( 'order' ); return $data_store->get_order_id_by_order_key( $order_key ); } /** * Get all registered order types. * * @since 2.2 * @param string $for Optionally define what you are getting order types for so * only relevant types are returned. * e.g. for 'order-meta-boxes', 'order-count'. * @return array */ function wc_get_order_types( $for = '' ) { global $wc_order_types; if ( ! is_array( $wc_order_types ) ) { $wc_order_types = array(); } $order_types = array(); switch ( $for ) { case 'order-count': foreach ( $wc_order_types as $type => $args ) { if ( ! $args['exclude_from_order_count'] ) { $order_types[] = $type; } } break; case 'order-meta-boxes': foreach ( $wc_order_types as $type => $args ) { if ( $args['add_order_meta_boxes'] ) { $order_types[] = $type; } } break; case 'view-orders': foreach ( $wc_order_types as $type => $args ) { if ( ! $args['exclude_from_order_views'] ) { $order_types[] = $type; } } break; case 'reports': foreach ( $wc_order_types as $type => $args ) { if ( ! $args['exclude_from_order_reports'] ) { $order_types[] = $type; } } break; case 'sales-reports': foreach ( $wc_order_types as $type => $args ) { if ( ! $args['exclude_from_order_sales_reports'] ) { $order_types[] = $type; } } break; case 'order-webhooks': foreach ( $wc_order_types as $type => $args ) { if ( ! $args['exclude_from_order_webhooks'] ) { $order_types[] = $type; } } break; case 'cot-migration': foreach ( $wc_order_types as $type => $args ) { if ( DataSynchronizer::PLACEHOLDER_ORDER_POST_TYPE !== $type ) { $order_types[] = $type; } } break; case 'admin-menu': $order_types = array_intersect( array_keys( $wc_order_types ), get_post_types( array( 'show_ui' => true, 'show_in_menu' => 'woocommerce', ) ) ); break; default: $order_types = array_keys( $wc_order_types ); break; } return apply_filters( 'wc_order_types', $order_types, $for ); } /** * Get an order type by post type name. * * @param string $type Post type name. * @return bool|array Details about the order type. */ function wc_get_order_type( $type ) { global $wc_order_types; if ( isset( $wc_order_types[ $type ] ) ) { return $wc_order_types[ $type ]; } return false; } /** * Register order type. Do not use before init. * * Wrapper for register post type, as well as a method of telling WC which. * post types are types of orders, and having them treated as such. * * $args are passed to register_post_type, but there are a few specific to this function: * - add_order_meta_boxes (bool) Whether or not the order type gets shop_order meta boxes. * - exclude_from_order_count (bool) Whether or not this order type is excluded from counts. * - exclude_from_order_views (bool) Whether or not this order type is visible by customers when. * viewing orders e.g. on the my account page. * - exclude_from_order_reports (bool) Whether or not to exclude this type from core reports. * - exclude_from_order_sales_reports (bool) Whether or not to exclude this type from core sales reports. * * @since 2.2 * @see register_post_type for $args used in that function * @param string $type Post type. (max. 20 characters, can not contain capital letters or spaces). * @param array $args An array of arguments. * @return bool Success or failure */ function wc_register_order_type( $type, $args = array() ) { if ( post_type_exists( $type ) ) { return false; } global $wc_order_types; if ( ! is_array( $wc_order_types ) ) { $wc_order_types = array(); } // Register as a post type. if ( is_wp_error( register_post_type( $type, $args ) ) ) { return false; } // Register for WC usage. $order_type_args = array( 'add_order_meta_boxes' => true, 'exclude_from_order_count' => false, 'exclude_from_order_views' => false, 'exclude_from_order_webhooks' => false, 'exclude_from_order_reports' => false, 'exclude_from_order_sales_reports' => false, 'class_name' => 'WC_Order', ); $args = array_intersect_key( $args, $order_type_args ); $args = wp_parse_args( $args, $order_type_args ); $wc_order_types[ $type ] = $args; return true; } /** * Return the count of processing orders. * * @return int */ function wc_processing_order_count() { return wc_orders_count( OrderStatus::PROCESSING ); } /** * Return the orders count of a specific order status. * * @param string $status Status. * @param string $type (Optional) Order type. Leave empty to include all 'for order-count' order types. @{see wc_get_order_types()}. * @return int */ function wc_orders_count( $status, string $type = '' ) { $count = 0; $legacy_statuses = array( OrderStatus::DRAFT, OrderStatus::TRASH, ); $status = ( ! in_array( $status, $legacy_statuses, true ) && 0 !== strpos( $status, 'wc-' ) ) ? 'wc-' . $status : $status; $valid_types = wc_get_order_types( 'order-count' ); $type = trim( $type ); try { $types_for_count = $type ? array( $type ) : $valid_types; $order_count_cache = new OrderCountCache(); foreach ( $types_for_count as $type ) { $cache = $order_count_cache->get( $type, array( $status ) ); if ( false !== $cache && isset( $cache[ $status ] ) ) { $count += $cache[ $status ]; } else { $count_for_type = OrderUtil::get_count_for_type( $type ); $count += $count_for_type[ $status ]; } } return $count; } catch ( Exception $e ) { return 0; } } /** * Grant downloadable product access to the file identified by $download_id. * * @param string $download_id File identifier. * @param int|WC_Product $product Product instance or ID. * @param WC_Order $order Order data. * @param int $qty Quantity purchased. * @param WC_Order_Item $item Item of the order. * @return int|bool insert id or false on failure. */ function wc_downloadable_file_permission( $download_id, $product, $order, $qty = 1, $item = null ) { if ( is_numeric( $product ) ) { $product = wc_get_product( $product ); } $download = new WC_Customer_Download(); $download->set_download_id( $download_id ); $download->set_product_id( $product->get_id() ); $download->set_user_id( $order->get_customer_id() ); $download->set_order_id( $order->get_id() ); $download->set_user_email( $order->get_billing_email() ); $download->set_order_key( $order->get_order_key() ); $download->set_downloads_remaining( 0 > $product->get_download_limit() ? '' : $product->get_download_limit() * $qty ); $download->set_access_granted( time() ); $download->set_download_count( 0 ); $expiry = $product->get_download_expiry(); if ( $expiry > 0 ) { $from_date = $order->get_date_completed() ? $order->get_date_completed()->format( 'Y-m-d' ) : current_time( 'mysql', true ); $download->set_access_expires( strtotime( $from_date . ' + ' . $expiry . ' DAY' ) ); } $download = apply_filters( 'woocommerce_downloadable_file_permission', $download, $product, $order, $qty, $item ); return $download->save(); } /** * Order Status completed - give downloadable product access to customer. * * @param int $order_id Order ID. * @param bool $force Force downloadable permissions. */ function wc_downloadable_product_permissions( $order_id, $force = false ) { $order = wc_get_order( $order_id ); if ( ! $order || ( $order->get_data_store()->get_download_permissions_granted( $order ) && ! $force ) ) { return; } if ( $order->has_status( OrderStatus::PROCESSING ) && 'no' === get_option( 'woocommerce_downloads_grant_access_after_payment' ) ) { return; } if ( count( $order->get_items() ) > 0 ) { foreach ( $order->get_items() as $item ) { $product = $item->get_product(); if ( $product && $product->exists() && $product->is_downloadable() ) { $downloads = $product->get_downloads(); foreach ( array_keys( $downloads ) as $download_id ) { wc_downloadable_file_permission( $download_id, $product, $order, $item->get_quantity(), $item ); } } } } $order->get_data_store()->set_download_permissions_granted( $order, true ); do_action( 'woocommerce_grant_product_download_permissions', $order_id ); } add_action( 'woocommerce_order_status_completed', 'wc_downloadable_product_permissions' ); add_action( 'woocommerce_order_status_processing', 'wc_downloadable_product_permissions' ); /** * Clear all transients cache for order data. * * @param int|WC_Order $order Order instance or ID. */ function wc_delete_shop_order_transients( $order = 0 ) { if ( is_numeric( $order ) ) { $order = wc_get_order( $order ); } $reports = WC_Admin_Reports::get_reports(); $transients_to_clear = array( 'wc_admin_report', ); foreach ( $reports as $report_group ) { foreach ( $report_group['reports'] as $report_key => $report ) { $transients_to_clear[] = 'wc_report_' . $report_key; } } foreach ( $transients_to_clear as $transient ) { delete_transient( $transient ); } // Clear customer's order related caches. if ( is_a( $order, 'WC_Order' ) ) { $order_id = $order->get_id(); Users::delete_site_user_meta( $order->get_customer_id(), 'wc_money_spent' ); Users::delete_site_user_meta( $order->get_customer_id(), 'wc_order_count' ); Users::delete_site_user_meta( $order->get_customer_id(), 'wc_last_order' ); } else { $order_id = 0; } // Increments the transient version to invalidate cache. WC_Cache_Helper::get_transient_version( 'orders', true ); // Do the same for regular cache. WC_Cache_Helper::invalidate_cache_group( 'orders' ); do_action( 'woocommerce_delete_shop_order_transients', $order_id ); } /** * See if we only ship to billing addresses. * * @return bool */ function wc_ship_to_billing_address_only() { return 'billing_only' === get_option( 'woocommerce_ship_to_destination' ); } /** * Create a new order refund programmatically. * * Returns a new refund object on success which can then be used to add additional data. * * @since 2.2 * @throws Exception Throws exceptions when fail to create, but returns WP_Error instead. * @param array $args New refund arguments. * @return WC_Order_Refund|WP_Error */ function wc_create_refund( $args = array() ) { $default_args = array( 'amount' => 0, 'reason' => null, 'order_id' => 0, 'refund_id' => 0, 'line_items' => array(), 'refund_payment' => false, 'restock_items' => false, ); try { $args = wp_parse_args( $args, $default_args ); $order = wc_get_order( $args['order_id'] ); if ( ! $order ) { throw new Exception( __( 'Invalid order ID.', 'woocommerce' ) ); } $remaining_refund_amount = $order->get_remaining_refund_amount(); $remaining_refund_items = $order->get_remaining_refund_items(); $refund_item_count = 0; $refund = new WC_Order_Refund( $args['refund_id'] ); $refunded_order_and_products = array(); if ( 0 > $args['amount'] || $args['amount'] > $remaining_refund_amount ) { throw new Exception( __( 'Invalid refund amount.', 'woocommerce' ) ); } $refund->set_currency( $order->get_currency() ); $refund->set_amount( $args['amount'] ); $refund->set_parent_id( absint( $args['order_id'] ) ); $refund->set_refunded_by( get_current_user_id() ? get_current_user_id() : 1 ); $refund->set_prices_include_tax( $order->get_prices_include_tax() ); if ( ! is_null( $args['reason'] ) ) { $refund->set_reason( $args['reason'] ); } // Negative line items. if ( is_array( $args['line_items'] ) && count( $args['line_items'] ) > 0 ) { $items = $order->get_items( array( 'line_item', 'fee', 'shipping' ) ); foreach ( $items as $item_id => $item ) { if ( ! isset( $args['line_items'][ $item_id ] ) ) { continue; } $qty = isset( $args['line_items'][ $item_id ]['qty'] ) ? $args['line_items'][ $item_id ]['qty'] : 0; $refund_total = $args['line_items'][ $item_id ]['refund_total']; $refund_tax = isset( $args['line_items'][ $item_id ]['refund_tax'] ) ? array_filter( (array) $args['line_items'][ $item_id ]['refund_tax'] ) : array(); if ( empty( $qty ) && empty( $refund_total ) && empty( $args['line_items'][ $item_id ]['refund_tax'] ) ) { continue; } // array of order id and product id which were refunded. // later to be used for revoking download permission. // checking if the item is a product, as we only need to revoke download permission for products. if ( $item->is_type( 'line_item' ) ) { $refunded_order_and_products[ $item_id ] = array( 'order_id' => $order->get_id(), 'product_id' => $item->get_product_id(), ); } $class = get_class( $item ); $refunded_item = new $class( $item ); $refunded_item->set_id( 0 ); $refunded_item->add_meta_data( '_refunded_item_id', $item_id, true ); $refunded_item->set_total( wc_format_refund_total( $refund_total ) ); $refunded_item->set_taxes( array( 'total' => array_map( 'wc_format_refund_total', $refund_tax ), 'subtotal' => array_map( 'wc_format_refund_total', $refund_tax ), ) ); if ( is_callable( array( $refunded_item, 'set_subtotal' ) ) ) { $refunded_item->set_subtotal( wc_format_refund_total( $refund_total ) ); } if ( is_callable( array( $refunded_item, 'set_quantity' ) ) ) { $refunded_item->set_quantity( $qty * -1 ); } $refund->add_item( $refunded_item ); $refund_item_count += $qty; } } $refund->update_taxes(); $refund->calculate_totals( false ); $refund->set_total( $args['amount'] * -1 ); // this should remain after update_taxes(), as this will save the order, and write the current date to the db // so we must wait until the order is persisted to set the date. if ( isset( $args['date_created'] ) ) { $refund->set_date_created( $args['date_created'] ); } /** * Action hook to adjust refund before save. * * @since 3.0.0 */ do_action( 'woocommerce_create_refund', $refund, $args ); if ( $refund->save() ) { if ( $args['refund_payment'] ) { $result = wc_refund_payment( $order, $refund->get_amount(), $refund->get_reason() ); if ( is_wp_error( $result ) ) { $refund->delete(); return $result; } $refund->set_refunded_payment( true ); $refund->save(); } if ( $args['restock_items'] ) { wc_restock_refunded_items( $order, $args['line_items'] ); } // delete downloads that were refunded using order and product id, if present. if ( ! empty( $refunded_order_and_products ) ) { foreach ( $refunded_order_and_products as $refunded_order_and_product ) { $download_data_store = WC_Data_Store::load( 'customer-download' ); $downloads = $download_data_store->get_downloads( $refunded_order_and_product ); if ( ! empty( $downloads ) ) { foreach ( $downloads as $download ) { $download_data_store->delete_by_id( $download->get_id() ); } } } } /** * Trigger notification emails. * * Filter hook to modify the partially-refunded status conditions. * * @since 6.7.0 * * @param bool $is_partially_refunded Whether the order is partially refunded. * @param int $order_id The order id. * @param int $refund_id The refund id. */ if ( (bool) apply_filters( 'woocommerce_order_is_partially_refunded', ( $remaining_refund_amount - $args['amount'] ) > 0 || ( $order->has_free_item() && ( $remaining_refund_items - $refund_item_count ) > 0 ), $order->get_id(), $refund->get_id() ) ) { do_action( 'woocommerce_order_partially_refunded', $order->get_id(), $refund->get_id() ); } else { do_action( 'woocommerce_order_fully_refunded', $order->get_id(), $refund->get_id() ); /** * Filter the status to set the order to when fully refunded. * * @since 2.7.0 * * @param string $parent_status The status to set the order to when fully refunded. * @param int $order_id The order ID. * @param int $refund_id The refund ID. */ $parent_status = apply_filters( 'woocommerce_order_fully_refunded_status', OrderStatus::REFUNDED, $order->get_id(), $refund->get_id() ); if ( $parent_status ) { $order->update_status( $parent_status ); } } } $order->set_date_modified( time() ); if ( wc_get_container()->get( CostOfGoodsSoldController::class )->feature_is_enabled() && $order->has_cogs() ) { $order->calculate_cogs_total_value(); } $order->save(); do_action( 'woocommerce_refund_created', $refund->get_id(), $args ); do_action( 'woocommerce_order_refunded', $order->get_id(), $refund->get_id() ); } catch ( Exception $e ) { if ( isset( $refund ) && is_a( $refund, 'WC_Order_Refund' ) ) { $refund->delete( true ); } return new WP_Error( 'error', $e->getMessage() ); } return $refund; } /** * Try to refund the payment for an order via the gateway. * * @since 3.0.0 * @throws Exception Throws exceptions when fail to refund, but returns WP_Error instead. * @param WC_Order $order Order instance. * @param string $amount Amount to refund. * @param string $reason Refund reason. * @return bool|WP_Error */ function wc_refund_payment( $order, $amount, $reason = '' ) { try { if ( ! is_a( $order, 'WC_Order' ) ) { throw new Exception( __( 'Invalid order.', 'woocommerce' ) ); } $gateway_controller = WC_Payment_Gateways::instance(); $all_gateways = $gateway_controller->payment_gateways(); $payment_method = $order->get_payment_method(); $gateway = isset( $all_gateways[ $payment_method ] ) ? $all_gateways[ $payment_method ] : false; if ( ! $gateway ) { throw new Exception( __( 'The payment gateway for this order does not exist.', 'woocommerce' ) ); } if ( ! $gateway->supports( 'refunds' ) ) { throw new Exception( __( 'The payment gateway for this order does not support automatic refunds.', 'woocommerce' ) ); } $result = $gateway->process_refund( $order->get_id(), $amount, $reason ); if ( ! $result ) { throw new Exception( __( 'An error occurred while attempting to create the refund using the payment gateway API.', 'woocommerce' ) ); } if ( is_wp_error( $result ) ) { throw new Exception( $result->get_error_message() ); } return true; } catch ( Exception $e ) { return new WP_Error( 'error', $e->getMessage() ); } } /** * Restock items during refund. * * @since 3.0.0 * @param WC_Order $order Order instance. * @param array $refunded_line_items Refunded items list. */ function wc_restock_refunded_items( $order, $refunded_line_items ) { if ( ! apply_filters( 'woocommerce_can_restock_refunded_items', true, $order, $refunded_line_items ) ) { return; } $line_items = $order->get_items(); foreach ( $line_items as $item_id => $item ) { if ( ! isset( $refunded_line_items[ $item_id ], $refunded_line_items[ $item_id ]['qty'] ) ) { continue; } $product = $item->get_product(); $item_stock_reduced = $item->get_meta( '_reduced_stock', true ); $restock_refunded_items = (int) $item->get_meta( '_restock_refunded_items', true ); $qty_to_refund = $refunded_line_items[ $item_id ]['qty']; if ( ! $item_stock_reduced || ! $qty_to_refund || ! $product || ! $product->managing_stock() ) { continue; } $old_stock = $product->get_stock_quantity(); $new_stock = wc_update_product_stock( $product, $qty_to_refund, 'increase' ); // Update _reduced_stock meta to track changes. $item_stock_reduced = $item_stock_reduced - $qty_to_refund; // Keeps track of total running tally of reduced stock. $item->update_meta_data( '_reduced_stock', $item_stock_reduced ); // Keeps track of only refunded items that needs restock. $item->update_meta_data( '_restock_refunded_items', $qty_to_refund + $restock_refunded_items ); /* translators: 1: product ID 2: old stock level 3: new stock level */ $restock_note = sprintf( __( 'Item #%1$s stock increased from %2$s to %3$s.', 'woocommerce' ), $product->get_id(), $old_stock, $new_stock ); /** * Allow the restock note to be modified. * * @since 6.4.0 * * @param string $restock_note The original note. * @param int $old_stock The old stock. * @param bool|int|null $new_stock The new stock. * @param WC_Order $order The order the refund was done for. * @param bool|WC_Product $product The product the refund was done for. */ $restock_note = apply_filters( 'woocommerce_refund_restock_note', $restock_note, $old_stock, $new_stock, $order, $product ); $order->add_order_note( $restock_note ); $item->save(); do_action( 'woocommerce_restock_refunded_item', $product->get_id(), $old_stock, $new_stock, $order, $product ); } } /** * Get tax class by tax id. * * @since 2.2 * @param int $tax_id Tax ID. * @return string */ function wc_get_tax_class_by_tax_id( $tax_id ) { global $wpdb; return $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_class FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %d", $tax_id ) ); } /** * Get payment gateway class by order data. * * @since 2.2 * @param int|WC_Order $order Order instance. * @return WC_Payment_Gateway|bool */ function wc_get_payment_gateway_by_order( $order ) { if ( WC()->payment_gateways() ) { $payment_gateways = WC()->payment_gateways()->payment_gateways(); } else { $payment_gateways = array(); } if ( ! is_object( $order ) ) { $order_id = absint( $order ); $order = wc_get_order( $order_id ); } return is_a( $order, 'WC_Order' ) && isset( $payment_gateways[ $order->get_payment_method() ] ) ? $payment_gateways[ $order->get_payment_method() ] : false; } /** * When refunding an order, create a refund line item if the partial refunds do not match order total. * * This is manual; no gateway refund will be performed. * * @since 2.4 * @param int $order_id Order ID. */ function wc_order_fully_refunded( $order_id ) { $order = wc_get_order( $order_id ); $max_refund = wc_format_decimal( $order->get_total() - $order->get_total_refunded() ); if ( ! $max_refund ) { return; } // Create the refund object. wc_switch_to_site_locale(); wc_create_refund( array( 'amount' => $max_refund, 'reason' => __( 'Order fully refunded.', 'woocommerce' ), 'order_id' => $order_id, 'line_items' => array(), ) ); wc_restore_locale(); $order->add_order_note( __( 'Order status set to refunded. To return funds to the customer you will need to issue a refund through your payment gateway.', 'woocommerce' ) ); } add_action( 'woocommerce_order_status_refunded', 'wc_order_fully_refunded' ); /** * Search orders. * * @since 2.6.0 * @param string $term Term to search. * @return array List of orders ID. */ function wc_order_search( $term ) { $data_store = WC_Data_Store::load( 'order' ); return $data_store->search_orders( str_replace( 'Order #', '', wc_clean( $term ) ) ); } /** * Update total sales amount for each product within a paid order. * * @since 3.0.0 * @param int $order_id Order ID. */ function wc_update_total_sales_counts( $order_id ) { $order = wc_get_order( $order_id ); if ( ! $order ) { return; } $recorded_sales = $order->get_data_store()->get_recorded_sales( $order ); $reflected_order = in_array( $order->get_status(), array( OrderStatus::CANCELLED, OrderStatus::TRASH ), true ); if ( ! $reflected_order && 'woocommerce_before_delete_order' === current_action() ) { $reflected_order = true; } if ( $recorded_sales xor $reflected_order ) { return; } $operation = $recorded_sales && $reflected_order ? 'decrease' : 'increase'; if ( count( $order->get_items() ) > 0 ) { foreach ( $order->get_items() as $item ) { $product_id = $item->get_product_id(); if ( $product_id ) { $data_store = WC_Data_Store::load( 'product' ); $data_store->update_product_sales( $product_id, absint( $item->get_quantity() ), $operation ); } } } if ( 'decrease' === $operation ) { $order->get_data_store()->set_recorded_sales( $order, false ); } else { $order->get_data_store()->set_recorded_sales( $order, true ); } /** * Called when sales for an order are recorded * * @param int $order_id order id */ do_action( 'woocommerce_recorded_sales', $order_id ); } add_action( 'woocommerce_order_status_completed', 'wc_update_total_sales_counts' ); add_action( 'woocommerce_order_status_processing', 'wc_update_total_sales_counts' ); add_action( 'woocommerce_order_status_on-hold', 'wc_update_total_sales_counts' ); add_action( 'woocommerce_order_status_completed_to_cancelled', 'wc_update_total_sales_counts' ); add_action( 'woocommerce_order_status_processing_to_cancelled', 'wc_update_total_sales_counts' ); add_action( 'woocommerce_order_status_on-hold_to_cancelled', 'wc_update_total_sales_counts' ); add_action( 'woocommerce_trash_order', 'wc_update_total_sales_counts' ); add_action( 'woocommerce_untrash_order', 'wc_update_total_sales_counts' ); add_action( 'woocommerce_before_delete_order', 'wc_update_total_sales_counts' ); /** * Update used coupon amount for each coupon within an order. * * @since 3.0.0 * @param int $order_id Order ID. */ function wc_update_coupon_usage_counts( $order_id ) { $order = wc_get_order( $order_id ); if ( ! $order ) { return; } $has_recorded = $order->get_data_store()->get_recorded_coupon_usage_counts( $order ); $invalid_statuses = array( OrderStatus::CANCELLED, OrderStatus::FAILED, OrderStatus::TRASH ); /** * Allow invalid order status filtering for updating coupon usage. * * @since 9.0.0 * * @param array $invalid_statuses Array of statuses to consider invalid. */ $invalid_statuses = apply_filters( 'woocommerce_update_coupon_usage_invalid_statuses', $invalid_statuses ); if ( $order->has_status( $invalid_statuses ) && $has_recorded ) { $action = 'reduce'; $order->get_data_store()->set_recorded_coupon_usage_counts( $order, false ); } elseif ( ! $order->has_status( $invalid_statuses ) && ! $has_recorded ) { $action = 'increase'; $order->get_data_store()->set_recorded_coupon_usage_counts( $order, true ); } elseif ( $order->has_status( $invalid_statuses ) ) { wc_release_coupons_for_order( $order ); return; } else { return; } if ( count( $order->get_coupon_codes() ) > 0 ) { foreach ( $order->get_coupon_codes() as $code ) { if ( StringUtil::is_null_or_whitespace( $code ) ) { continue; } $coupon = new WC_Coupon( $code ); $used_by = $order->get_user_id(); if ( ! $used_by ) { $used_by = $order->get_billing_email(); } switch ( $action ) { case 'reduce': $coupon->decrease_usage_count( $used_by ); break; case 'increase': $coupon->increase_usage_count( $used_by, $order ); break; } } wc_release_coupons_for_order( $order ); } } add_action( 'woocommerce_order_status_pending', 'wc_update_coupon_usage_counts' ); add_action( 'woocommerce_order_status_completed', 'wc_update_coupon_usage_counts' ); add_action( 'woocommerce_order_status_processing', 'wc_update_coupon_usage_counts' ); add_action( 'woocommerce_order_status_on-hold', 'wc_update_coupon_usage_counts' ); add_action( 'woocommerce_order_status_cancelled', 'wc_update_coupon_usage_counts' ); add_action( 'woocommerce_order_status_failed', 'wc_update_coupon_usage_counts' ); add_action( 'woocommerce_trash_order', 'wc_update_coupon_usage_counts' ); /** * Cancel all unpaid orders after held duration to prevent stock lock for those products. */ function wc_cancel_unpaid_orders() { $held_duration = get_option( 'woocommerce_hold_stock_minutes' ); // Re-schedule the event before cancelling orders // this way in case of a DB timeout or (plugin) crash the event is always scheduled for retry. wp_clear_scheduled_hook( 'woocommerce_cancel_unpaid_orders' ); $cancel_unpaid_interval = apply_filters( 'woocommerce_cancel_unpaid_orders_interval_minutes', absint( $held_duration ) ); wp_schedule_single_event( time() + ( absint( $cancel_unpaid_interval ) * 60 ), 'woocommerce_cancel_unpaid_orders' ); if ( $held_duration < 1 || 'yes' !== get_option( 'woocommerce_manage_stock' ) ) { return; } $data_store = WC_Data_Store::load( 'order' ); $unpaid_orders = $data_store->get_unpaid_orders( strtotime( '-' . absint( $held_duration ) . ' MINUTES', current_time( 'timestamp' ) ) ); if ( $unpaid_orders ) { foreach ( $unpaid_orders as $unpaid_order ) { $order = wc_get_order( $unpaid_order ); if ( apply_filters( 'woocommerce_cancel_unpaid_order', 'checkout' === $order->get_created_via(), $order ) ) { $order->update_status( OrderStatus::CANCELLED, __( 'Unpaid order cancelled - time limit reached.', 'woocommerce' ) ); } } } } add_action( 'woocommerce_cancel_unpaid_orders', 'wc_cancel_unpaid_orders' ); /** * Sanitize order id removing unwanted characters. * * E.g Users can sometimes try to track an order id using # with no success. * This function will fix this. * * @since 3.1.0 * @param int $order_id Order ID. */ function wc_sanitize_order_id( $order_id ) { return (int) filter_var( $order_id, FILTER_SANITIZE_NUMBER_INT ); } add_filter( 'woocommerce_shortcode_order_tracking_order_id', 'wc_sanitize_order_id' ); /** * Get an order note. * * @since 3.2.0 * @param int|WP_Comment $data Note ID (or WP_Comment instance for internal use only). * @return stdClass|null Object with order note details or null when does not exists. */ function wc_get_order_note( $data ) { if ( is_numeric( $data ) ) { $data = get_comment( $data ); } if ( ! is_a( $data, 'WP_Comment' ) ) { return null; } return (object) apply_filters( 'woocommerce_get_order_note', array( 'id' => (int) $data->comment_ID, 'date_created' => wc_string_to_datetime( $data->comment_date ), 'content' => $data->comment_content, 'customer_note' => (bool) get_comment_meta( $data->comment_ID, 'is_customer_note', true ), 'added_by' => __( 'WooCommerce', 'woocommerce' ) === $data->comment_author ? 'system' : $data->comment_author, 'order_id' => absint( $data->comment_post_ID ), ), $data ); } /** * Get order notes. * * @since 3.2.0 * @param array $args Query arguments { * Array of query parameters. * * @type string $limit Maximum number of notes to retrieve. * Default empty (no limit). * @type int $order_id Limit results to those affiliated with a given order ID. * Default 0. * @type array $order__in Array of order IDs to include affiliated notes for. * Default empty. * @type array $order__not_in Array of order IDs to exclude affiliated notes for. * Default empty. * @type string $orderby Define how should sort notes. * Accepts 'date_created', 'date_created_gmt' or 'id'. * Default: 'id'. * @type string $order How to order retrieved notes. * Accepts 'ASC' or 'DESC'. * Default: 'DESC'. * @type string $type Define what type of note should retrieve. * Accepts 'customer', 'internal' or empty for both. * Default empty. * } * @return stdClass[] Array of stdClass objects with order notes details. */ function wc_get_order_notes( $args ) { $key_mapping = array( 'limit' => 'number', 'order_id' => 'post_id', 'order__in' => 'post__in', 'order__not_in' => 'post__not_in', ); foreach ( $key_mapping as $query_key => $db_key ) { if ( isset( $args[ $query_key ] ) ) { $args[ $db_key ] = $args[ $query_key ]; unset( $args[ $query_key ] ); } } // Define orderby. $orderby_mapping = array( 'date_created' => 'comment_date', 'date_created_gmt' => 'comment_date_gmt', 'id' => 'comment_ID', ); $args['orderby'] = ! empty( $args['orderby'] ) && in_array( $args['orderby'], array( 'date_created', 'date_created_gmt', 'id' ), true ) ? $orderby_mapping[ $args['orderby'] ] : 'comment_ID'; // Set WooCommerce order type. if ( isset( $args['type'] ) && 'customer' === $args['type'] ) { $args['meta_query'] = array( // WPCS: slow query ok. array( 'key' => 'is_customer_note', 'value' => 1, 'compare' => '=', ), ); } elseif ( isset( $args['type'] ) && 'internal' === $args['type'] ) { $args['meta_query'] = array( // WPCS: slow query ok. array( 'key' => 'is_customer_note', 'compare' => 'NOT EXISTS', ), ); } // Set correct comment type. $args['type'] = 'order_note'; // Always approved. $args['status'] = 'approve'; // Does not support 'count' or 'fields'. unset( $args['count'], $args['fields'] ); remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); $notes = get_comments( $args ); add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); return array_filter( array_map( 'wc_get_order_note', $notes ) ); } /** * Create an order note. * * @since 3.2.0 * @param int $order_id Order ID. * @param string $note Note to add. * @param bool $is_customer_note If is a costumer note. * @param bool $added_by_user If note is create by an user. * @return int|WP_Error Integer when created or WP_Error when found an error. */ function wc_create_order_note( $order_id, $note, $is_customer_note = false, $added_by_user = false ) { $order = wc_get_order( $order_id ); if ( ! $order ) { return new WP_Error( 'invalid_order_id', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 400 ) ); } return $order->add_order_note( $note, (int) $is_customer_note, $added_by_user ); } /** * Delete an order note. * * @since 3.2.0 * @param int $note_id Order note. * @return bool True on success, false on failure. */ function wc_delete_order_note( $note_id ) { $note = wc_get_order_note( $note_id ); if ( $note && wp_delete_comment( $note_id, true ) ) { /** * Action hook fired after an order note is deleted. * * @param int $note_id Order note ID. * @param stdClass $note Object with the deleted order note details. * * @since 9.1.0 */ do_action( 'woocommerce_order_note_deleted', $note_id, $note ); return true; } return false; }// ColorBox v1.3.19 - jQuery lightbox plugin // (c) 2011 Jack Moore - jacklmoore.com // License: http://www.opensource.org/licenses/mit-license.php (function(a,b,c){function Z(c,d,e){var g=b.createElement(c);return d&&(g.id=f+d),e&&(g.style.cssText=e),a(g)}function $(a){var b=y.length,c=(Q+a)%b;return c<0?b+c:c}function _(a,b){return Math.round((/%/.test(a)?(b==="x"?z.width():z.height())/100:1)*parseInt(a,10))}function ba(a){return K.photo||/\.(gif|png|jpe?g|bmp|ico)((#|\?).*)?$/i.test(a)}function bb(){var b;K=a.extend({},a.data(P,e));for(b in K)a.isFunction(K[b])&&b.slice(0,2)!=="on"&&(K[b]=K[b].call(P));K.rel=K.rel||P.rel||"nofollow",K.href=K.href||a(P).attr("href"),K.title=K.title||P.title,typeof K.href=="string"&&(K.href=a.trim(K.href))}function bc(b,c){a.event.trigger(b),c&&c.call(P)}function bd(){var a,b=f+"Slideshow_",c="click."+f,d,e,g;K.slideshow&&y[1]?(d=function(){F.text(K.slideshowStop).unbind(c).bind(j,function(){if(K.loop||y[Q+1])a=setTimeout(W.next,K.slideshowSpeed)}).bind(i,function(){clearTimeout(a)}).one(c+" "+k,e),r.removeClass(b+"off").addClass(b+"on"),a=setTimeout(W.next,K.slideshowSpeed)},e=function(){clearTimeout(a),F.text(K.slideshowStart).unbind([j,i,k,c].join(" ")).one(c,function(){W.next(),d()}),r.removeClass(b+"on").addClass(b+"off")},K.slideshowAuto?d():e()):r.removeClass(b+"off "+b+"on")}function be(b){U||(P=b,bb(),y=a(P),Q=0,K.rel!=="nofollow"&&(y=a("."+g).filter(function(){var b=a.data(this,e).rel||this.rel;return b===K.rel}),Q=y.index(P),Q===-1&&(y=y.add(P),Q=y.length-1)),S||(S=T=!0,r.show(),K.returnFocus&&a(P).blur().one(l,function(){a(this).focus()}),q.css({opacity:+K.opacity,cursor:K.overlayClose?"pointer":"auto"}).show(),K.w=_(K.initialWidth,"x"),K.h=_(K.initialHeight,"y"),W.position(),o&&z.bind("resize."+p+" scroll."+p,function(){q.css({width:z.width(),height:z.height(),top:z.scrollTop(),left:z.scrollLeft()})}).trigger("resize."+p),bc(h,K.onOpen),J.add(D).hide(),I.html(K.close).show()),W.load(!0))}function bf(){!r&&b.body&&(Y=!1,z=a(c),r=Z(X).attr({id:e,"class":n?f+(o?"IE6":"IE"):""}).hide(),q=Z(X,"Overlay",o?"position:absolute":"").hide(),s=Z(X,"Wrapper"),t=Z(X,"Content").append(A=Z(X,"LoadedContent","width:0; height:0; overflow:hidden"),C=Z(X,"LoadingOverlay").add(Z(X,"LoadingGraphic")),D=Z(X,"Title"),E=Z(X,"Current"),G=Z(X,"Next"),H=Z(X,"Previous"),F=Z(X,"Slideshow").bind(h,bd),I=Z(X,"Close")),s.append(Z(X).append(Z(X,"TopLeft"),u=Z(X,"TopCenter"),Z(X,"TopRight")),Z(X,!1,"clear:left").append(v=Z(X,"MiddleLeft"),t,w=Z(X,"MiddleRight")),Z(X,!1,"clear:left").append(Z(X,"BottomLeft"),x=Z(X,"BottomCenter"),Z(X,"BottomRight"))).find("div div").css({"float":"left"}),B=Z(X,!1,"position:absolute; width:9999px; visibility:hidden; display:none"),J=G.add(H).add(E).add(F),a(b.body).append(q,r.append(s,B)))}function bg(){return r?(Y||(Y=!0,L=u.height()+x.height()+t.outerHeight(!0)-t.height(),M=v.width()+w.width()+t.outerWidth(!0)-t.width(),N=A.outerHeight(!0),O=A.outerWidth(!0),r.css({"padding-bottom":L,"padding-right":M}),G.click(function(){W.next()}),H.click(function(){W.prev()}),I.click(function(){W.close()}),q.click(function(){K.overlayClose&&W.close()}),a(b).bind("keydown."+f,function(a){var b=a.keyCode;S&&K.escKey&&b===27&&(a.preventDefault(),W.close()),S&&K.arrowKey&&y[1]&&(b===37?(a.preventDefault(),H.click()):b===39&&(a.preventDefault(),G.click()))}),a("."+g,b).live("click",function(a){a.which>1||a.shiftKey||a.altKey||a.metaKey||(a.preventDefault(),be(this))})),!0):!1}var d={transition:"elastic",speed:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,inline:!1,html:!1,iframe:!1,fastIframe:!0,photo:!1,href:!1,title:!1,rel:!1,opacity:.9,preloading:!0,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:!1,returnFocus:!0,reposition:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1,overlayClose:!0,escKey:!0,arrowKey:!0,top:!1,bottom:!1,left:!1,right:!1,fixed:!1,data:undefined},e="colorbox",f="cbox",g=f+"Element",h=f+"_open",i=f+"_load",j=f+"_complete",k=f+"_cleanup",l=f+"_closed",m=f+"_purge",n=!a.support.opacity&&!a.support.style,o=n&&!c.XMLHttpRequest,p=f+"_IE6",q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X="div",Y;if(a.colorbox)return;a(bf),W=a.fn[e]=a[e]=function(b,c){var f=this;b=b||{},bf();if(bg()){if(!f[0]){if(f.selector)return f;f=a(""),b.open=!0}c&&(b.onComplete=c),f.each(function(){a.data(this,e,a.extend({},a.data(this,e)||d,b))}).addClass(g),(a.isFunction(b.open)&&b.open.call(f)||b.open)&&be(f[0])}return f},W.position=function(a,b){function i(a){u[0].style.width=x[0].style.width=t[0].style.width=a.style.width,t[0].style.height=v[0].style.height=w[0].style.height=a.style.height}var c=0,d=0,e=r.offset(),g=z.scrollTop(),h=z.scrollLeft();z.unbind("resize."+f),r.css({top:-9e4,left:-9e4}),K.fixed&&!o?(e.top-=g,e.left-=h,r.css({position:"fixed"})):(c=g,d=h,r.css({position:"absolute"})),K.right!==!1?d+=Math.max(z.width()-K.w-O-M-_(K.right,"x"),0):K.left!==!1?d+=_(K.left,"x"):d+=Math.round(Math.max(z.width()-K.w-O-M,0)/2),K.bottom!==!1?c+=Math.max(z.height()-K.h-N-L-_(K.bottom,"y"),0):K.top!==!1?c+=_(K.top,"y"):c+=Math.round(Math.max(z.height()-K.h-N-L,0)/2),r.css({top:e.top,left:e.left}),a=r.width()===K.w+O&&r.height()===K.h+N?0:a||0,s[0].style.width=s[0].style.height="9999px",r.dequeue().animate({width:K.w+O,height:K.h+N,top:c,left:d},{duration:a,complete:function(){i(this),T=!1,s[0].style.width=K.w+O+M+"px",s[0].style.height=K.h+N+L+"px",K.reposition&&setTimeout(function(){z.bind("resize."+f,W.position)},1),b&&b()},step:function(){i(this)}})},W.resize=function(a){S&&(a=a||{},a.width&&(K.w=_(a.width,"x")-O-M),a.innerWidth&&(K.w=_(a.innerWidth,"x")),A.css({width:K.w}),a.height&&(K.h=_(a.height,"y")-N-L),a.innerHeight&&(K.h=_(a.innerHeight,"y")),!a.innerHeight&&!a.height&&(A.css({height:"auto"}),K.h=A.height()),A.css({height:K.h}),W.position(K.transition==="none"?0:K.speed))},W.prep=function(b){function g(){return K.w=K.w||A.width(),K.w=K.mw&&K.mw1){typeof K.current=="string"&&E.html(K.current.replace("{current}",Q+1).replace("{total}",g)).show(),G[K.loop||QK.mw&&(a=(R.width-K.mw)/R.width,d()),K.mh&&R.height>K.mh&&(a=(R.height-K.mh)/R.height,d())),K.h&&(R.style.marginTop=Math.max(K.h-R.height,0)/2+"px"),y[1]&&(K.loop||y[Q+1])&&(R.style.cursor="pointer",R.onclick=function(){W.next()}),n&&(R.style.msInterpolationMode="bicubic"),setTimeout(function(){e(R)},1)}),setTimeout(function(){R.src=c},1)):c&&B.load(c,K.data,function(b,c,d){e(c==="error"?Z(X,"Error").text("Request unsuccessful: "+d.statusText):a(this).contents())})},W.next=function(){!T&&y[1]&&(K.loop||y[Q+1])&&(Q=$(1),W.load())},W.prev=function(){!T&&y[1]&&(K.loop||Q)&&(Q=$(-1),W.load())},W.close=function(){S&&!U&&(U=!0,S=!1,bc(k,K.onCleanup),z.unbind("."+f+" ."+p),q.fadeTo(200,0),r.stop().fadeTo(300,0,function(){r.add(q).css({opacity:1,cursor:"auto"}).hide(),bc(m),A.remove(),setTimeout(function(){U=!1,bc(l,K.onClosed)},1)}))},W.remove=function(){a([]).add(r).add(q).remove(),r=null,a("."+g).removeData(e).removeClass(g).die()},W.element=function(){return a(P)},W.settings=d})(jQuery,document,this);

this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["product-best-sellers"]=function(e){function t(t){for(var r,l,i=t[0],s=t[1],a=t[2],d=0,b=[];dObject(o.sprintf)( /* translators: Number of items selected from list. */ Object(o._n)("%d item selected","%d items selected",e,'woocommerce'),e),updated:Object(o.__)("Search results updated.",'woocommerce')},i=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;const c=Object(n.groupBy)(e,"parent"),r=Object(n.keyBy)(t,"id"),o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e.parent)return e.name?[e.name]:[];const t=o(r[e.parent]);return[...t,e.name]},l=e=>e.map(e=>{const t=c[e.id];return delete c[e.id],{...e,breadcrumbs:o(r[e.parent]),children:t&&t.length?l(t):[]}}),i=l(c[0]||[]);return delete c[0],Object(n.forEach)(c,e=>{i.push(...l(e||[]))}),i},s=(e,t,c)=>{if(!t)return c?i(e):e;const r=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),n=e.map(e=>!!r.test(e.name)&&e).filter(Boolean);return c?i(n,e):n},a=(e,t)=>{if(!t)return e;const c=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"ig");return e.split(c).map((e,c)=>0===c?e:Object(r.createElement)(r.Fragment,{key:c},Object(r.createElement)("strong",null,t),e))},u=e=>1===e.length?e.slice(0,1).toString():2===e.length?e.slice(0,1).toString()+" › "+e.slice(-1).toString():e.slice(0,1).toString()+" … "+e.slice(-1).toString()},18:function(e,t){e.exports=window.wp.primitives},2:function(e,t){e.exports=window.wc.wcSettings},24:function(e,t,c){"use strict";c.d(t,"o",(function(){return o})),c.d(t,"m",(function(){return l})),c.d(t,"l",(function(){return i})),c.d(t,"n",(function(){return s})),c.d(t,"j",(function(){return a})),c.d(t,"e",(function(){return u})),c.d(t,"f",(function(){return d})),c.d(t,"g",(function(){return b})),c.d(t,"k",(function(){return m})),c.d(t,"c",(function(){return g})),c.d(t,"d",(function(){return h})),c.d(t,"h",(function(){return p})),c.d(t,"a",(function(){return E})),c.d(t,"i",(function(){return O})),c.d(t,"b",(function(){return w}));var r,n=c(2);const o=Object(n.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),l=o.pluginUrl+"images/",i=o.pluginUrl+"build/",s=o.buildPhase,a=null===(r=n.STORE_PAGES.shop)||void 0===r?void 0:r.permalink,u=n.STORE_PAGES.checkout.id,d=n.STORE_PAGES.checkout.permalink,b=n.STORE_PAGES.privacy.permalink,m=(n.STORE_PAGES.privacy.title,n.STORE_PAGES.terms.permalink),g=(n.STORE_PAGES.terms.title,n.STORE_PAGES.cart.id),h=n.STORE_PAGES.cart.permalink,p=(n.STORE_PAGES.myaccount.permalink?n.STORE_PAGES.myaccount.permalink:Object(n.getSetting)("wpLoginUrl","/wp-login.php"),Object(n.getSetting)("shippingCountries",{})),E=Object(n.getSetting)("allowedCountries",{}),O=Object(n.getSetting)("shippingStates",{}),w=Object(n.getSetting)("allowedStates",{})},27:function(e,t,c){"use strict";c.d(t,"h",(function(){return a})),c.d(t,"e",(function(){return u})),c.d(t,"b",(function(){return d})),c.d(t,"i",(function(){return b})),c.d(t,"f",(function(){return m})),c.d(t,"c",(function(){return g})),c.d(t,"d",(function(){return h})),c.d(t,"g",(function(){return p})),c.d(t,"a",(function(){return E}));var r=c(15),n=c(11),o=c.n(n),l=c(6),i=c(2),s=c(24);const a=e=>{let{selected:t=[],search:c="",queryArgs:n={}}=e;const i=(e=>{let{selected:t=[],search:c="",queryArgs:n={}}=e;const o=s.o.productCount>100,l={per_page:o?100:0,catalog_visibility:"any",search:c,orderby:"title",order:"asc"},i=[Object(r.addQueryArgs)("/wc/store/products",{...l,...n})];return o&&t.length&&i.push(Object(r.addQueryArgs)("/wc/store/products",{catalog_visibility:"any",include:t,per_page:0})),i})({selected:t,search:c,queryArgs:n});return Promise.all(i.map(e=>o()({path:e}))).then(e=>Object(l.uniqBy)(Object(l.flatten)(e),"id").map(e=>({...e,parent:0}))).catch(e=>{throw e})},u=e=>o()({path:"/wc/store/products/"+e}),d=()=>o()({path:"wc/store/products/attributes"}),b=e=>o()({path:`wc/store/products/attributes/${e}/terms`}),m=e=>{let{selected:t=[],search:c}=e;const n=(e=>{let{selected:t=[],search:c}=e;const n=Object(i.getSetting)("limitTags",!1),o=[Object(r.addQueryArgs)("wc/store/products/tags",{per_page:n?100:0,orderby:n?"count":"name",order:n?"desc":"asc",search:c})];return n&&t.length&&o.push(Object(r.addQueryArgs)("wc/store/products/tags",{include:t})),o})({selected:t,search:c});return Promise.all(n.map(e=>o()({path:e}))).then(e=>Object(l.uniqBy)(Object(l.flatten)(e),"id"))},g=e=>o()({path:Object(r.addQueryArgs)("wc/store/products/categories",{per_page:0,...e})}),h=e=>o()({path:"wc/store/products/categories/"+e}),p=e=>o()({path:Object(r.addQueryArgs)("wc/store/products",{per_page:0,type:"variation",parent:e})}),E=(e,t)=>{if(!e.title.raw)return e.slug;const c=1===t.filter(t=>t.title.raw===e.title.raw).length;return e.title.raw+(c?"":" - "+e.slug)}},28:function(e,t,c){"use strict";c.d(t,"a",(function(){return n})),c.d(t,"b",(function(){return o}));var r=c(1);const n=async e=>{if("function"==typeof e.json)try{const t=await e.json();return{message:t.message,type:t.type||"api"}}catch(e){return{message:e.message,type:"general"}}return{message:e.message,type:e.type||"general"}},o=e=>{if(e.data&&"rest_invalid_param"===e.code){const t=Object.values(e.data.params);if(t[0])return t[0]}return(null==e?void 0:e.message)||Object(r.__)("Something went wrong. Please contact us to get assistance.",'woocommerce')}},3:function(e,t){e.exports=window.wp.components},31:function(e,t){e.exports=window.wp.escapeHtml},32:function(e,t,c){"use strict";var r=c(0),n=c(1),o=c(31);t.a=e=>{let{error:t}=e;return Object(r.createElement)("div",{className:"wc-block-error-message"},(e=>{let{message:t,type:c}=e;return t?"general"===c?Object(r.createElement)("span",null,Object(n.__)("The following error was returned",'woocommerce'),Object(r.createElement)("br",null),Object(r.createElement)("code",null,Object(o.escapeHTML)(t))):"api"===c?Object(r.createElement)("span",null,Object(n.__)("The following error was returned from the API",'woocommerce'),Object(r.createElement)("br",null),Object(r.createElement)("code",null,Object(o.escapeHTML)(t))):t:Object(n.__)("An unknown error occurred which prevented the block from being updated.",'woocommerce')})(t))}},325:function(e,t,c){e.exports=c(459)},33:function(e,t,c){"use strict";c.d(t,"a",(function(){return i}));var r=c(5),n=c.n(r),o=c(0),l=c(17);const i=e=>{let{countLabel:t,className:c,depth:r=0,controlId:i="",item:s,isSelected:a,isSingle:u,onSelect:d,search:b="",...m}=e;const g=null!=t&&void 0!==s.count&&null!==s.count,h=[c,"woocommerce-search-list__item"];h.push("depth-"+r),u&&h.push("is-radio-button"),g&&h.push("has-count");const p=s.breadcrumbs&&s.breadcrumbs.length,E=m.name||"search-list-item-"+i,O=`${E}-${s.id}`;return Object(o.createElement)("label",{htmlFor:O,className:h.join(" ")},u?Object(o.createElement)("input",n()({type:"radio",id:O,name:E,value:s.value,onChange:d(s),checked:a,className:"woocommerce-search-list__item-input"},m)):Object(o.createElement)("input",n()({type:"checkbox",id:O,name:E,value:s.value,onChange:d(s),checked:a,className:"woocommerce-search-list__item-input"},m)),Object(o.createElement)("span",{className:"woocommerce-search-list__item-label"},p?Object(o.createElement)("span",{className:"woocommerce-search-list__item-prefix"},Object(l.b)(s.breadcrumbs)):null,Object(o.createElement)("span",{className:"woocommerce-search-list__item-name"},Object(l.d)(s.name,b))),!!g&&Object(o.createElement)("span",{className:"woocommerce-search-list__item-count"},t||s.count))};t.b=i},43:function(e,t,c){"use strict";var r=c(0);t.a=function(e){let{srcElement:t,size:c=24,...n}=e;return Object(r.isValidElement)(t)?Object(r.cloneElement)(t,{width:c,height:c,...n}):null}},459:function(e,t,c){"use strict";c.r(t);var r=c(0),n=c(1),o=c(6),l=c(43),i=c(18),s=Object(r.createElement)(i.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(r.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(r.createElement)("path",{d:"M3.5 18.49l6-6.01 4 4L22 6.92l-1.41-1.41-7.09 7.97-4-4L2 16.99l1.5 1.5z"})),a=c(12),u=c(3),d=c(7),b=c(51),m=c.n(b),g=(c(10),c(58)),h=c(59),p=c(64),E=c(128),O=c(2);class w extends r.Component{getInspectorControls(){const{attributes:e,setAttributes:t}=this.props,{categories:c,catOperator:o,columns:l,contentVisibility:i,rows:s,alignButtons:a}=e;return Object(r.createElement)(d.InspectorControls,{key:"inspector"},Object(r.createElement)(u.PanelBody,{title:Object(n.__)("Layout",'woocommerce'),initialOpen:!0},Object(r.createElement)(h.a,{columns:l,rows:s,alignButtons:a,setAttributes:t,minColumns:Object(O.getSetting)("min_columns",1),maxColumns:Object(O.getSetting)("max_columns",6),minRows:Object(O.getSetting)("min_rows",1),maxRows:Object(O.getSetting)("max_rows",6)})),Object(r.createElement)(u.PanelBody,{title:Object(n.__)("Content",'woocommerce'),initialOpen:!0},Object(r.createElement)(g.a,{settings:i,onChange:e=>t({contentVisibility:e})})),Object(r.createElement)(u.PanelBody,{title:Object(n.__)("Filter by Product Category",'woocommerce'),initialOpen:!1},Object(r.createElement)(p.a,{selected:c,onChange:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const c=e.map(e=>{let{id:t}=e;return t});t({categories:c})},operator:o,onOperatorChange:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"any";return t({catOperator:e})}})))}render(){const{attributes:e,name:t}=this.props;return e.isPreview?E.a:Object(r.createElement)("div",{className:"wc-block-product-best-sellers"},this.getInspectorControls(),Object(r.createElement)(u.Disabled,null,Object(r.createElement)(m.a,{block:t,attributes:e})))}}var j=w,f=c(72);Object(a.registerBlockType)("woocommerce/product-best-sellers",{title:Object(n.__)("Best Selling Products",'woocommerce'),icon:{src:Object(r.createElement)(l.a,{srcElement:s,className:"wc-block-editor-components-block-icon"})},category:"woocommerce",keywords:[Object(n.__)("WooCommerce",'woocommerce')],description:Object(n.__)("Display a grid of your all-time best selling products.",'woocommerce'),supports:{align:["wide","full"],html:!1},example:{attributes:{isPreview:!0}},attributes:{...f.a},transforms:{from:[{type:"block",blocks:Object(o.without)(f.b,"woocommerce/product-best-sellers"),transform:e=>Object(a.createBlock)("woocommerce/product-best-sellers",e)}]},edit:e=>Object(r.createElement)(j,e),save:()=>null})},51:function(e,t){e.exports=window.wp.serverSideRender},58:function(e,t,c){"use strict";var r=c(0),n=c(1),o=(c(10),c(3));t.a=e=>{let{onChange:t,settings:c}=e;const{button:l,price:i,rating:s,title:a}=c;return Object(r.createElement)(r.Fragment,null,Object(r.createElement)(o.ToggleControl,{label:Object(n.__)("Product title",'woocommerce'),help:a?Object(n.__)("Product title is visible.",'woocommerce'):Object(n.__)("Product title is hidden.",'woocommerce'),checked:a,onChange:()=>t({...c,title:!a})}),Object(r.createElement)(o.ToggleControl,{label:Object(n.__)("Product price",'woocommerce'),help:i?Object(n.__)("Product price is visible.",'woocommerce'):Object(n.__)("Product price is hidden.",'woocommerce'),checked:i,onChange:()=>t({...c,price:!i})}),Object(r.createElement)(o.ToggleControl,{label:Object(n.__)("Product rating",'woocommerce'),help:s?Object(n.__)("Product rating is visible.",'woocommerce'):Object(n.__)("Product rating is hidden.",'woocommerce'),checked:s,onChange:()=>t({...c,rating:!s})}),Object(r.createElement)(o.ToggleControl,{label:Object(n.__)("Add to Cart button",'woocommerce'),help:l?Object(n.__)("Add to Cart button is visible.",'woocommerce'):Object(n.__)("Add to Cart button is hidden.",'woocommerce'),checked:l,onChange:()=>t({...c,button:!l})}))}},59:function(e,t,c){"use strict";var r=c(0),n=c(1),o=c(6),l=(c(10),c(3));t.a=e=>{let{columns:t,rows:c,setAttributes:i,alignButtons:s,minColumns:a=1,maxColumns:u=6,minRows:d=1,maxRows:b=6}=e;return Object(r.createElement)(r.Fragment,null,Object(r.createElement)(l.RangeControl,{label:Object(n.__)("Columns",'woocommerce'),value:t,onChange:e=>{const t=Object(o.clamp)(e,a,u);i({columns:Number.isNaN(t)?"":t})},min:a,max:u}),Object(r.createElement)(l.RangeControl,{label:Object(n.__)("Rows",'woocommerce'),value:c,onChange:e=>{const t=Object(o.clamp)(e,d,b);i({rows:Number.isNaN(t)?"":t})},min:d,max:b}),Object(r.createElement)(l.ToggleControl,{label:Object(n.__)("Align Last Block",'woocommerce'),help:s?Object(n.__)("The last inner block will be aligned vertically.",'woocommerce'):Object(n.__)("The last inner block will follow other content.",'woocommerce'),checked:s,onChange:()=>i({alignButtons:!s})}))}},6:function(e,t){e.exports=window.lodash},64:function(e,t,c){"use strict";var r=c(5),n=c.n(r),o=c(0),l=c(1),i=(c(10),c(33)),s=c(87),a=c(3),u=c(9),d=c(27),b=c(28),m=Object(u.createHigherOrderComponent)(e=>class extends o.Component{constructor(){super(...arguments),this.state={error:null,loading:!1,categories:[]},this.loadCategories=this.loadCategories.bind(this)}componentDidMount(){this.loadCategories()}loadCategories(){this.setState({loading:!0}),Object(d.c)().then(e=>{this.setState({categories:e,loading:!1,error:null})}).catch(async e=>{const t=await Object(b.a)(e);this.setState({categories:[],loading:!1,error:t})})}render(){const{error:t,loading:c,categories:r}=this.state;return Object(o.createElement)(e,n()({},this.props,{error:t,isLoading:c,categories:r}))}},"withCategories"),g=c(32),h=c(4),p=c.n(h);c(91);const E=e=>{let{categories:t,error:c,isLoading:r,onChange:u,onOperatorChange:d,operator:b,selected:m,isCompact:h,isSingle:E,showReviewCount:O}=e;const w={clear:Object(l.__)("Clear all product categories",'woocommerce'),list:Object(l.__)("Product Categories",'woocommerce'),noItems:Object(l.__)("Your store doesn't have any product categories.",'woocommerce'),search:Object(l.__)("Search for product categories",'woocommerce'),selected:e=>Object(l.sprintf)( /* translators: %d is the count of selected categories. */ Object(l._n)("%d category selected","%d categories selected",e,'woocommerce'),e),updated:Object(l.__)("Category search results updated.",'woocommerce')};return c?Object(o.createElement)(g.a,{error:c}):Object(o.createElement)(o.Fragment,null,Object(o.createElement)(s.a,{className:"woocommerce-product-categories",list:t,isLoading:r,selected:m.map(e=>t.find(t=>t.id===e)).filter(Boolean),onChange:u,renderItem:e=>{const{item:t,search:c,depth:r=0}=e,s=t.breadcrumbs.length?`${t.breadcrumbs.join(", ")}, ${t.name}`:t.name,a=O?Object(l.sprintf)( /* translators: %1$s is the item name, %2$d is the count of reviews for the item. */ Object(l._n)("%1$s, has %2$d review","%1$s, has %2$d reviews",t.review_count,'woocommerce'),s,t.review_count):Object(l.sprintf)( /* translators: %1$s is the item name, %2$d is the count of products for the item. */ Object(l._n)("%1$s, has %2$d product","%1$s, has %2$d products",t.count,'woocommerce'),s,t.count),u=O?Object(l.sprintf)( /* translators: %d is the count of reviews. */ Object(l._n)("%d review","%d reviews",t.review_count,'woocommerce'),t.review_count):Object(l.sprintf)( /* translators: %d is the count of products. */ Object(l._n)("%d product","%d products",t.count,'woocommerce'),t.count);return Object(o.createElement)(i.a,n()({className:p()("woocommerce-product-categories__item","has-count",{"is-searching":c.length>0,"is-skip-level":0===r&&0!==t.parent})},e,{countLabel:u,"aria-label":a}))},messages:w,isCompact:h,isHierarchical:!0,isSingle:E}),!!d&&Object(o.createElement)("div",{hidden:m.length<2},Object(o.createElement)(a.SelectControl,{className:"woocommerce-product-categories__operator",label:Object(l.__)("Display products matching",'woocommerce'),help:Object(l.__)("Pick at least two categories to use this setting.",'woocommerce'),value:b,onChange:d,options:[{label:Object(l.__)("Any selected categories",'woocommerce'),value:"any"},{label:Object(l.__)("All selected categories",'woocommerce'),value:"all"}]})))};E.defaultProps={operator:"any",isCompact:!1,isSingle:!1},t.a=m(E)},7:function(e,t){e.exports=window.wp.blockEditor},72:function(e,t,c){"use strict";c.d(t,"b",(function(){return n}));var r=c(2);const n=["woocommerce/product-best-sellers","woocommerce/product-category","woocommerce/product-new","woocommerce/product-on-sale","woocommerce/product-top-rated"];t.a={columns:{type:"number",default:Object(r.getSetting)("default_columns",3)},rows:{type:"number",default:Object(r.getSetting)("default_rows",3)},alignButtons:{type:"boolean",default:!1},categories:{type:"array",default:[]},catOperator:{type:"string",default:"any"},contentVisibility:{type:"object",default:{title:!0,price:!0,rating:!0,button:!0}},isPreview:{type:"boolean",default:!1},stockStatus:{type:"array",default:Object.keys(Object(r.getSetting)("stockStatusOptions",[]))}}},87:function(e,t,c){"use strict";c.d(t,"a",(function(){return y}));var r=c(5),n=c.n(r),o=c(0),l=c(1),i=c(3),s=c(485),a=c(487),u=c(4),d=c.n(u),b=c(9),m=c(17),g=c(33),h=c(486),p=c(14);const E=e=>{let{id:t,label:c,popoverContents:r,remove:n,screenReaderLabel:a,className:u=""}=e;const[m,g]=Object(o.useState)(!1),O=Object(b.useInstanceId)(E);if(a=a||c,!c)return null;c=Object(p.decodeEntities)(c);const w=d()("woocommerce-tag",u,{"has-remove":!!n}),j="woocommerce-tag__label-"+O,f=Object(o.createElement)(o.Fragment,null,Object(o.createElement)("span",{className:"screen-reader-text"},a),Object(o.createElement)("span",{"aria-hidden":"true"},c));return Object(o.createElement)("span",{className:w},r?Object(o.createElement)(i.Button,{className:"woocommerce-tag__text",id:j,onClick:()=>g(!0)},f):Object(o.createElement)("span",{className:"woocommerce-tag__text",id:j},f),r&&m&&Object(o.createElement)(i.Popover,{onClose:()=>g(!1)},r),n&&Object(o.createElement)(i.Button,{className:"woocommerce-tag__remove",onClick:n(t),label:Object(l.sprintf)(// Translators: %s label. Object(l.__)("Remove %s",'woocommerce'),c),"aria-describedby":j},Object(o.createElement)(s.a,{icon:h.a,size:20,className:"clear-icon"})))};var O=E;const w=e=>Object(o.createElement)(g.b,e),j=e=>{const{list:t,selected:c,renderItem:r,depth:l=0,onSelect:i,instanceId:s,isSingle:a,search:u}=e;return t?Object(o.createElement)(o.Fragment,null,t.map(t=>{const d=-1!==c.findIndex(e=>{let{id:c}=e;return c===t.id});return Object(o.createElement)(o.Fragment,{key:t.id},Object(o.createElement)("li",null,r({item:t,isSelected:d,onSelect:i,isSingle:a,search:u,depth:l,controlId:s})),Object(o.createElement)(j,n()({},e,{list:t.children,depth:l+1})))})):null},f=e=>{let{isLoading:t,isSingle:c,selected:r,messages:n,onChange:s,onRemove:a}=e;if(t||c||!r)return null;const u=r.length;return Object(o.createElement)("div",{className:"woocommerce-search-list__selected"},Object(o.createElement)("div",{className:"woocommerce-search-list__selected-header"},Object(o.createElement)("strong",null,n.selected(u)),u>0?Object(o.createElement)(i.Button,{isLink:!0,isDestructive:!0,onClick:()=>s([]),"aria-label":n.clear},Object(l.__)("Clear all",'woocommerce')):null),u>0?Object(o.createElement)("ul",null,r.map((e,t)=>Object(o.createElement)("li",{key:t},Object(o.createElement)(O,{label:e.name,id:e.id,remove:a})))):null)},_=e=>{let{filteredList:t,search:c,onSelect:r,instanceId:n,...i}=e;const{messages:u,renderItem:d,selected:b,isSingle:m}=i,g=d||w;return 0===t.length?Object(o.createElement)("div",{className:"woocommerce-search-list__list is-not-found"},Object(o.createElement)("span",{className:"woocommerce-search-list__not-found-icon"},Object(o.createElement)(s.a,{icon:a.a})),Object(o.createElement)("span",{className:"woocommerce-search-list__not-found-text"},c?Object(l.sprintf)(u.noResults,c):u.noItems)):Object(o.createElement)("ul",{className:"woocommerce-search-list__list"},Object(o.createElement)(j,{list:t,selected:b,renderItem:g,onSelect:r,instanceId:n,isSingle:m,search:c}))},y=e=>{const{className:t="",isCompact:c,isHierarchical:r,isLoading:l,isSingle:s,list:a,messages:u=m.a,onChange:g,onSearch:h,selected:p,debouncedSpeak:E}=e,[O,w]=Object(o.useState)(""),j=Object(b.useInstanceId)(y),x=Object(o.useMemo)(()=>({...m.a,...u}),[u]),k=Object(o.useMemo)(()=>Object(m.c)(a,O,r),[a,O,r]);Object(o.useEffect)(()=>{E&&E(x.updated)},[E,x]),Object(o.useEffect)(()=>{"function"==typeof h&&h(O)},[O,h]);const v=Object(o.useCallback)(e=>()=>{s&&g([]);const t=p.findIndex(t=>{let{id:c}=t;return c===e});g([...p.slice(0,t),...p.slice(t+1)])},[s,p,g]),S=Object(o.useCallback)(e=>()=>{-1===p.findIndex(t=>{let{id:c}=t;return c===e.id})?g(s?[e]:[...p,e]):v(e.id)()},[s,v,g,p]);return Object(o.createElement)("div",{className:d()("woocommerce-search-list",t,{"is-compact":c})},Object(o.createElement)(f,n()({},e,{onRemove:v,messages:x})),Object(o.createElement)("div",{className:"woocommerce-search-list__search"},Object(o.createElement)(i.TextControl,{label:x.search,type:"search",value:O,onChange:e=>w(e)})),l?Object(o.createElement)("div",{className:"woocommerce-search-list__list is-loading"},Object(o.createElement)(i.Spinner,null)):Object(o.createElement)(_,n()({},e,{search:O,filteredList:k,messages:x,onSelect:S,instanceId:j})))};Object(i.withSpokenMessages)(y)},9:function(e,t){e.exports=window.wp.compose},91:function(e,t){}});