Version Description
WordPress Coding Standards, Variation product link not opening parent variable product on Stock log page, Incorrect plugin slug and text domain at few places, Plugin name broken in admin footer text on Stock Manager pages, Check product instance before calling product functions, Stock log page, Removed unused code, POT file
Download this release
Release Info
Developer | storeapps |
Plugin | WooCommerce Stock Manager |
Version | 2.8.0 |
Comparing to | |
See all releases |
Code changes from version 2.7.0 to 2.8.0
- admin/assets/css/index.php +10 -1
- admin/assets/index.php +10 -1
- admin/assets/js/admin.js +0 -249
- admin/assets/js/index.php +10 -1
- admin/assets/package-lock.json +1 -1
- admin/assets/package.json +4 -4
- admin/class-stock-manager-admin.php +149 -134
- admin/includes/{wcm-class-save.php → class-wsm-save.php} +53 -89
- admin/includes/class-wsm-stock.php +325 -0
- admin/includes/config.php +0 -34
- admin/includes/index.php +9 -1
- admin/includes/wcm-class-stock.php +0 -342
- admin/includes/wcm-class-table.php +0 -800
- admin/views/admin.php +14 -131
- admin/views/{class-storeapps-marketplace.php → class-wsm-storeapps-marketplace.php} +19 -7
- admin/views/components/filter.php +0 -147
- admin/views/import-export.php +107 -95
- admin/views/index.php +10 -1
- admin/views/log-history.php +45 -35
- admin/views/log.php +57 -50
- admin/views/setting.php +37 -27
- admin/views/stock-monitor.php +0 -57
- index.php +10 -1
- languages/index.php +10 -1
- languages/woocommerce-stock-manager.pot +163 -303
- public/class-stock-manager.php +68 -76
- readme.txt +15 -2
- sa-includes/class-sa-in-app-offers.php +2 -3
- vendor/autoload.php +0 -7
- vendor/automattic/woocommerce/.editorconfig +0 -19
- vendor/automattic/woocommerce/.gitignore +0 -3
- vendor/automattic/woocommerce/.scrutinizer.yml +0 -9
- vendor/automattic/woocommerce/.travis.yml +0 -18
- vendor/automattic/woocommerce/LICENSE +0 -21
- vendor/automattic/woocommerce/README.md +0 -158
- vendor/automattic/woocommerce/composer.json +0 -33
- vendor/automattic/woocommerce/phpcs.xml +0 -7
- vendor/automattic/woocommerce/phpunit.xml.dist +0 -20
- vendor/automattic/woocommerce/src/WooCommerce/Client.php +0 -109
- vendor/automattic/woocommerce/src/WooCommerce/HttpClient/BasicAuth.php +0 -95
- vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php +0 -444
- vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClientException.php +0 -70
- vendor/automattic/woocommerce/src/WooCommerce/HttpClient/OAuth.php +0 -268
- vendor/automattic/woocommerce/src/WooCommerce/HttpClient/Options.php +0 -148
- vendor/automattic/woocommerce/src/WooCommerce/HttpClient/Request.php +0 -187
- vendor/automattic/woocommerce/src/WooCommerce/HttpClient/Response.php +0 -113
- vendor/automattic/woocommerce/tests/WooCommerce/Tests/ClientTest.php +0 -16
- vendor/automattic/woocommerce/tests/WooCommerce/Tests/HttpClient/BasicAuthTest.php +0 -26
- vendor/automattic/woocommerce/tests/WooCommerce/Tests/HttpClient/HttpClientExceptionTest.php +0 -44
- vendor/automattic/woocommerce/tests/WooCommerce/Tests/HttpClient/OAuthTest.php +0 -35
- vendor/automattic/woocommerce/tests/WooCommerce/Tests/HttpClient/OptionsTest.php +0 -51
- vendor/automattic/woocommerce/tests/WooCommerce/Tests/HttpClient/RequestTest.php +0 -65
- vendor/automattic/woocommerce/tests/WooCommerce/Tests/HttpClient/ResponseTest.php +0 -40
- vendor/automattic/woocommerce/tests/bootstrap.php +0 -22
- vendor/composer/ClassLoader.php +0 -441
- vendor/composer/LICENSE +0 -21
- vendor/composer/autoload_classmap.php +0 -9
- vendor/composer/autoload_namespaces.php +0 -9
- vendor/composer/autoload_psr4.php +0 -10
- vendor/composer/autoload_real.php +0 -52
- vendor/composer/autoload_static.php +0 -31
- vendor/composer/installed.json +0 -52
- woocommerce-stock-manager.php +199 -152
admin/assets/css/index.php
CHANGED
@@ -1 +1,10 @@
|
|
1 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silence is golden
|
4 |
+
*
|
5 |
+
* @package woocommerce-stock-manager/admin/assets/css/
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
admin/assets/index.php
CHANGED
@@ -1 +1,10 @@
|
|
1 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silence is golden
|
4 |
+
*
|
5 |
+
* @package woocommerce-stock-manager/admin/assets/
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
admin/assets/js/admin.js
DELETED
@@ -1,249 +0,0 @@
|
|
1 |
-
// TODO: review this.
|
2 |
-
(function ( $ ) {
|
3 |
-
"use strict";
|
4 |
-
|
5 |
-
$(function () {
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Fix for
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
jQuery( '.manage_stock_select' ).on( 'change' , function() {
|
12 |
-
|
13 |
-
var id = jQuery( this ).data( 'item' );
|
14 |
-
var manage = jQuery( this ).val();
|
15 |
-
|
16 |
-
if( manage == 'no' ){
|
17 |
-
|
18 |
-
//jQuery( '.stock_status_' + id ).val( 'outofstock' );
|
19 |
-
jQuery( '.stock_status_' + id ).prop( 'disabled', false );
|
20 |
-
jQuery( '.backorders_' + id ).val( 'no' );
|
21 |
-
jQuery( '.backorders_' + id ).prop( 'disabled', 'disabled' );
|
22 |
-
jQuery( '.stock_' + id ).val( '0' );
|
23 |
-
jQuery( '.stock_' + id ).prop( 'disabled', 'disabled' );
|
24 |
-
|
25 |
-
}else{
|
26 |
-
|
27 |
-
jQuery( '.stock_status_' + id ).prop( 'disabled', 'disabled' );
|
28 |
-
jQuery( '.backorders_' + id ).prop( 'disabled', false );
|
29 |
-
jQuery( '.stock_' + id ).prop( 'disabled', false );
|
30 |
-
|
31 |
-
var data = {
|
32 |
-
'action' : 'wsm_get_product_data',
|
33 |
-
'productid' : id
|
34 |
-
};
|
35 |
-
|
36 |
-
jQuery.post( ajaxurl, data, function( response ) {
|
37 |
-
|
38 |
-
var result = jQuery.parseJSON( response );
|
39 |
-
|
40 |
-
if( result.stock_status ){
|
41 |
-
jQuery( '.stock_status_' + result.productid ).val( result.stock_status );
|
42 |
-
}
|
43 |
-
if( result.backorders ){
|
44 |
-
jQuery( '.backorders_' + result.productid ).val( result.backorders );
|
45 |
-
}
|
46 |
-
if( result.stock ){
|
47 |
-
jQuery( '.stock_' + result.productid ).val( result.stock );
|
48 |
-
}
|
49 |
-
|
50 |
-
});
|
51 |
-
|
52 |
-
}
|
53 |
-
|
54 |
-
});
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Fix for 2
|
58 |
-
*
|
59 |
-
*/
|
60 |
-
jQuery( '.backorders_select' ).on( 'change' , function(){
|
61 |
-
|
62 |
-
var id = jQuery( this ).data( 'item' );
|
63 |
-
var backorders = jQuery( this ).val();
|
64 |
-
|
65 |
-
if( backorders == 'no' ){
|
66 |
-
|
67 |
-
var number = jQuery( '.stock_' + id ).val();
|
68 |
-
|
69 |
-
if( number ){
|
70 |
-
if( number > 0 ){
|
71 |
-
jQuery( '.stock_status_' + id ).val( 'instock' );
|
72 |
-
}else{
|
73 |
-
jQuery( '.stock_status_' + id ).val( 'outofstock' );
|
74 |
-
}
|
75 |
-
}else{
|
76 |
-
jQuery( '.stock_status_' + id ).val( 'outofstock' );
|
77 |
-
}
|
78 |
-
|
79 |
-
}else{
|
80 |
-
|
81 |
-
jQuery( '.stock_status_' + id ).val( 'onbackorder' );
|
82 |
-
|
83 |
-
}
|
84 |
-
|
85 |
-
});
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Fix for 3
|
89 |
-
*
|
90 |
-
*/
|
91 |
-
jQuery( '.stock_number' ).on( 'change' , function(){
|
92 |
-
|
93 |
-
var id = jQuery( this ).data( 'item' );
|
94 |
-
var stock = jQuery( this ).val();
|
95 |
-
|
96 |
-
if( stock ){
|
97 |
-
if( stock > 0 ){
|
98 |
-
jQuery( '.stock_status_' + id ).val( 'instock' );
|
99 |
-
}else{
|
100 |
-
var backorder = jQuery( '.backorders_' + id ).val();
|
101 |
-
if( backorder == 'no' ){
|
102 |
-
jQuery( '.stock_status_' + id ).val( 'outofstock' );
|
103 |
-
}else{
|
104 |
-
jQuery( '.stock_status_' + id ).val( 'onbackorder' );
|
105 |
-
}
|
106 |
-
}
|
107 |
-
}else{
|
108 |
-
jQuery( '.stock_status_' + id ).val( 'outofstock' );
|
109 |
-
}
|
110 |
-
|
111 |
-
});
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Save single product line in stock table
|
115 |
-
*
|
116 |
-
*/
|
117 |
-
jQuery('.save-product').on('click', function(){
|
118 |
-
jQuery('.lineloader').css('display','block');
|
119 |
-
var product = jQuery(this).data('product');
|
120 |
-
var sku = jQuery('.sku_' + product).val();
|
121 |
-
var manage_stock = jQuery('.manage_stock_' + product).val();
|
122 |
-
var stock_status = jQuery('.stock_status_' + product).val();
|
123 |
-
var backorders = jQuery('.backorders_' + product).val();
|
124 |
-
var stock = jQuery('.stock_' + product).val();
|
125 |
-
var regular_price = jQuery('.regular_price_' + product).val();
|
126 |
-
var sales_price = jQuery('.sales_price_' + product).val();
|
127 |
-
var weight = jQuery('.weight_' + product).val();
|
128 |
-
var tax_status = jQuery('.tax_status' + product).val();
|
129 |
-
var tax_class = jQuery('.tax_class' + product).val();
|
130 |
-
var shipping_class = jQuery('.shipping_class' + product).val();
|
131 |
-
var secure = jQuery('.wsm-ajax-nonce_' + product).val();
|
132 |
-
|
133 |
-
var data = {
|
134 |
-
action : 'save_one_product',
|
135 |
-
product : product,
|
136 |
-
sku : sku,
|
137 |
-
manage_stock : manage_stock,
|
138 |
-
stock_status : stock_status,
|
139 |
-
backorders : backorders,
|
140 |
-
stock : stock,
|
141 |
-
regular_price : regular_price,
|
142 |
-
sales_price : sales_price,
|
143 |
-
weight : weight,
|
144 |
-
tax_status : tax_status,
|
145 |
-
tax_class : tax_class,
|
146 |
-
shipping_class : shipping_class,
|
147 |
-
secure : secure
|
148 |
-
};
|
149 |
-
|
150 |
-
jQuery.post(ajaxurl, data, function(response){
|
151 |
-
jQuery('.lineloader').css('display','none');
|
152 |
-
});
|
153 |
-
});
|
154 |
-
|
155 |
-
/**
|
156 |
-
* Show variations of selected product
|
157 |
-
*
|
158 |
-
*/
|
159 |
-
jQuery('.show-variable').on('click', function(){
|
160 |
-
var variable = jQuery(this).data('variable');
|
161 |
-
jQuery('.variation-item-' + variable).toggleClass('show-variations');
|
162 |
-
});
|
163 |
-
|
164 |
-
/**
|
165 |
-
* Navigation
|
166 |
-
*
|
167 |
-
*/
|
168 |
-
jQuery('.stock-manager-navigation li span').on('click', function(){
|
169 |
-
jQuery('.stock-manager-navigation li span').removeClass('activ');
|
170 |
-
jQuery(this).addClass('activ');
|
171 |
-
});
|
172 |
-
jQuery('.stock-manager-navigation li span.navigation-filter-default').on('click', function(){
|
173 |
-
jQuery('.filter-block').removeClass('active-filter');
|
174 |
-
jQuery('.stock-filter').addClass('active-filter');
|
175 |
-
});
|
176 |
-
jQuery('.stock-manager-navigation li span.navigation-filter-by-sku').on('click', function(){
|
177 |
-
jQuery('.filter-block').removeClass('active-filter');
|
178 |
-
jQuery('.filter-by-sku').addClass('active-filter');
|
179 |
-
});
|
180 |
-
jQuery('.stock-manager-navigation li span.navigation-filter-by-title').on('click', function(){
|
181 |
-
jQuery('.filter-block').removeClass('active-filter');
|
182 |
-
jQuery('.filter-by-title').addClass('active-filter');
|
183 |
-
});
|
184 |
-
jQuery('.stock-manager-navigation li span.navigation-filter-display').on('click', function(){
|
185 |
-
jQuery('.filter-block').removeClass('active-filter');
|
186 |
-
jQuery('.filter-display').addClass('active-filter');
|
187 |
-
});
|
188 |
-
|
189 |
-
//Open box for product title saving
|
190 |
-
jQuery('.table_name_box .dashicons').on('click', function(){
|
191 |
-
var item = jQuery(this).data('item');
|
192 |
-
jQuery('.item-post-title-wrap-'+item).css('display','block');
|
193 |
-
});
|
194 |
-
//Close box for product title saving
|
195 |
-
jQuery('.item-post-title-button-close').on('click', function(){
|
196 |
-
jQuery(this).parent().css('display', 'none');
|
197 |
-
});
|
198 |
-
//Save product title
|
199 |
-
jQuery('.item-post-title-button').on('click', function(ajax_object){
|
200 |
-
|
201 |
-
var item = jQuery(this).data('item');
|
202 |
-
var title = jQuery('.item-post-title-'+item).val();
|
203 |
-
var data = {
|
204 |
-
action : 'wsm_save_title_product',
|
205 |
-
item : item,
|
206 |
-
title : title,
|
207 |
-
secure : ajax_object.ajax_nonce
|
208 |
-
};
|
209 |
-
jQuery('.item-post-title-'+item).val(title);
|
210 |
-
jQuery('.item-post-link-'+item).text(title);
|
211 |
-
|
212 |
-
jQuery.post(ajaxurl, data, function(response, item, title){
|
213 |
-
jQuery('.item-post-title-wrap-'+response).css('display', 'none');
|
214 |
-
});
|
215 |
-
|
216 |
-
});
|
217 |
-
|
218 |
-
//Open box for sku saving
|
219 |
-
jQuery('.item_sku_box .dashicons').on('click', function(){
|
220 |
-
var item = jQuery(this).data('item');
|
221 |
-
jQuery('.item-sku-wrap-'+item).css('display','block');
|
222 |
-
});
|
223 |
-
//Close box for sku saving
|
224 |
-
jQuery('.item-sku-button-close').on('click', function(){
|
225 |
-
jQuery(this).parent().css('display', 'none');
|
226 |
-
});
|
227 |
-
//Save sku
|
228 |
-
jQuery('.item-sku-button').on('click', function(ajax_object){
|
229 |
-
|
230 |
-
var item = jQuery(this).data('item');
|
231 |
-
var sku = jQuery('.sku_'+item).val();
|
232 |
-
var data = {
|
233 |
-
action : 'wsm_save_sku',
|
234 |
-
item : item,
|
235 |
-
sku : sku,
|
236 |
-
secure : ajax_object.ajax_nonce
|
237 |
-
};
|
238 |
-
jQuery('.sku_-'+item).val(sku);
|
239 |
-
jQuery('.item-sku-text-'+item).text(sku);
|
240 |
-
|
241 |
-
jQuery.post(ajaxurl, data, function(response, item, sku){
|
242 |
-
jQuery('.item-sku-wrap-'+response).css('display', 'none');
|
243 |
-
});
|
244 |
-
|
245 |
-
});
|
246 |
-
|
247 |
-
});
|
248 |
-
|
249 |
-
}(jQuery));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/assets/js/index.php
CHANGED
@@ -1 +1,10 @@
|
|
1 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silence is golden
|
4 |
+
*
|
5 |
+
* @package woocommerce-stock-manager/admin/assets/js/
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
admin/assets/package-lock.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
{
|
2 |
"name": "woocommerce-stock-manager",
|
3 |
-
"version": "1.0.
|
4 |
"lockfileVersion": 1,
|
5 |
"requires": true,
|
6 |
"dependencies": {
|
1 |
{
|
2 |
"name": "woocommerce-stock-manager",
|
3 |
+
"version": "1.0.1",
|
4 |
"lockfileVersion": 1,
|
5 |
"requires": true,
|
6 |
"dependencies": {
|
admin/assets/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
{
|
2 |
"name": "woocommerce-stock-manager",
|
3 |
-
"version": "1.0.
|
4 |
"description": "Stock Manager for WooCommerce",
|
5 |
"main": "build/index.js",
|
6 |
"private": true,
|
@@ -10,11 +10,11 @@
|
|
10 |
},
|
11 |
"repository": {
|
12 |
"type": "git",
|
13 |
-
"url": "
|
14 |
},
|
15 |
-
"author": "Vladislav Musilek
|
16 |
"contributors": [
|
17 |
-
"
|
18 |
],
|
19 |
"license": "GPL",
|
20 |
"sideEffects": false,
|
1 |
{
|
2 |
"name": "woocommerce-stock-manager",
|
3 |
+
"version": "1.0.1",
|
4 |
"description": "Stock Manager for WooCommerce",
|
5 |
"main": "build/index.js",
|
6 |
"private": true,
|
10 |
},
|
11 |
"repository": {
|
12 |
"type": "git",
|
13 |
+
"url": ""
|
14 |
},
|
15 |
+
"author": "Vladislav Musilek",
|
16 |
"contributors": [
|
17 |
+
""
|
18 |
],
|
19 |
"license": "GPL",
|
20 |
"sideEffects": false,
|
admin/class-stock-manager-admin.php
CHANGED
@@ -1,34 +1,37 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* @package woocommerce-stock-manager/admin/
|
4 |
-
* @version 2.
|
5 |
*/
|
6 |
|
7 |
if ( ! defined( 'ABSPATH' ) ) {
|
8 |
exit;
|
9 |
}
|
10 |
|
|
|
|
|
|
|
11 |
class Stock_Manager_Admin {
|
12 |
|
13 |
/**
|
14 |
* Instance of this class.
|
15 |
*
|
16 |
-
* @since 1.0.0
|
17 |
-
*
|
18 |
* @var object
|
19 |
*/
|
20 |
protected static $instance = null;
|
21 |
|
22 |
/**
|
23 |
-
* Initialize the plugin by loading admin scripts & styles and adding a
|
24 |
-
* settings page and menu.
|
25 |
-
*
|
26 |
-
* @since 1.0.0
|
27 |
*/
|
28 |
private function __construct() {
|
29 |
|
30 |
-
|
31 |
-
$this->
|
|
|
|
|
|
|
32 |
|
33 |
// Load admin style sheet and JavaScript.
|
34 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
|
@@ -36,9 +39,9 @@ class Stock_Manager_Admin {
|
|
36 |
|
37 |
// Add the options page and menu item.
|
38 |
add_action( 'admin_menu', array( $this, 'add_plugin_admin_menu' ) );
|
39 |
-
|
40 |
-
include_once
|
41 |
-
|
42 |
add_action( 'admin_notices', array( $this, 'includes' ) );
|
43 |
|
44 |
add_action( 'admin_init', array( $this, 'wsm_dismiss_admin_notice' ) );
|
@@ -51,31 +54,27 @@ class Stock_Manager_Admin {
|
|
51 |
/**
|
52 |
* Return an instance of this class.
|
53 |
*
|
54 |
-
* @since 1.0.0
|
55 |
-
*
|
56 |
* @return object A single instance of this class.
|
57 |
*/
|
58 |
public static function get_instance() {
|
59 |
|
60 |
// If the single instance hasn't been set, set it now.
|
61 |
-
if (
|
62 |
-
self::$instance = new self;
|
63 |
}
|
64 |
|
65 |
return self::$instance;
|
66 |
}
|
67 |
-
|
68 |
/**
|
69 |
* Include required core files used in admin.
|
70 |
-
*
|
71 |
-
* @since 1.0.0
|
72 |
*/
|
73 |
public function includes() {
|
74 |
$is_wsm_admin = $this->is_wsm_admin_page();
|
75 |
if ( $is_wsm_admin ) {
|
76 |
$this->may_be_show_sa_in_app_offer();
|
77 |
$this->wsm_add_subscribe_notice();
|
78 |
-
|
79 |
}
|
80 |
}
|
81 |
|
@@ -83,10 +82,8 @@ class Stock_Manager_Admin {
|
|
83 |
* Function to check if WSM admin page.
|
84 |
*/
|
85 |
public function is_wsm_admin_page() {
|
86 |
-
if
|
87 |
-
|
88 |
-
return true;
|
89 |
-
}
|
90 |
}
|
91 |
|
92 |
return false;
|
@@ -94,83 +91,95 @@ class Stock_Manager_Admin {
|
|
94 |
|
95 |
/**
|
96 |
* Get stock class
|
97 |
-
*
|
98 |
-
*
|
99 |
-
* @since 1.0.0
|
100 |
*/
|
101 |
public function stock() {
|
102 |
-
return
|
103 |
}
|
104 |
|
105 |
/**
|
106 |
* Register and enqueue admin-specific CSS.
|
107 |
-
* @since 1.0.0
|
108 |
-
*
|
109 |
-
* @return null Return early if no settings page is registered.
|
110 |
*/
|
111 |
public function enqueue_admin_styles() {
|
112 |
-
if
|
113 |
-
wp_enqueue_style(
|
114 |
|
115 |
$old_styles = get_option( 'woocommerce_stock_old_styles' );
|
116 |
-
if( !empty( $old_styles ) &&
|
117 |
-
wp_enqueue_style(
|
118 |
}
|
119 |
}
|
120 |
}
|
121 |
|
122 |
/**
|
123 |
* Register and enqueue admin-specific JavaScript.
|
124 |
-
* @since 1.0.0
|
125 |
-
*
|
126 |
-
* @return null Return early if no settings page is registered.
|
127 |
*/
|
128 |
public function enqueue_admin_scripts() {
|
129 |
-
if
|
130 |
$low_stock_threshold = get_option( 'woocommerce_notify_low_stock_amount', 5 );
|
131 |
$low_stock_threshold = ( ! empty( $low_stock_threshold ) ) ? $low_stock_threshold : 5;
|
132 |
|
133 |
-
|
134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
);
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
wp_enqueue_style( $this->plugin_slug .'-admin-script-react', plugins_url( 'assets/build/index.css', __FILE__ ), array(), WSM_PLUGIN_VERSION );
|
140 |
-
wp_enqueue_script( $this->plugin_slug . '-admin-script-react', plugins_url( 'assets/build/index.js', __FILE__ ), array( 'wp-polyfill', 'wp-i18n', 'wp-url' ), WSM_PLUGIN_VERSION );
|
141 |
-
wp_localize_script( $this->plugin_slug . '-admin-script-react', 'WooCommerceStockManagerPreloadedState', array(
|
142 |
-
'app'=> [
|
143 |
-
'textDomain' => $this->plugin_slug,
|
144 |
-
'root' => esc_url_raw(rest_url()),
|
145 |
-
'adminUrl' => admin_url(),
|
146 |
-
'nonce' => wp_create_nonce('wp_rest'),
|
147 |
-
'perPage' => apply_filters('woocommerce_stock_manager_per_page', 50),
|
148 |
-
'lowStockThreshold' => $low_stock_threshold,
|
149 |
-
],
|
150 |
-
'product-categories' => array_reduce(get_terms(['taxonomy' => 'product_cat', 'hide_empty' => false]), function($carry, $item) {
|
151 |
-
$carry[$item->term_id] = $item->name;
|
152 |
-
return $carry;
|
153 |
-
}, []),
|
154 |
-
'product-types' => wc_get_product_types(),
|
155 |
-
'stock-status-options' => wc_get_product_stock_status_options(),
|
156 |
-
'shipping-classes' => array_merge(array('' => __('No shipping class', 'woocommerce-stock-manager')), array_reduce(get_terms(['taxonomy' => 'product_shipping_class', 'hide_empty' => false]), function($carry, $item) {
|
157 |
-
$carry[$item->slug] = $item->name;
|
158 |
-
return $carry;
|
159 |
-
}, [])),
|
160 |
-
'tax-classes' => wc_get_product_tax_class_options(),
|
161 |
-
'tax-statuses' => [
|
162 |
-
'taxable' => __('Taxable', 'woocommerce-stock-manager'),
|
163 |
-
'shipping' => __('Shipping only', 'woocommerce-stock-manager'),
|
164 |
-
'none' => _x('None', 'Tax status', 'woocommerce-stock-manager'),
|
165 |
-
],
|
166 |
-
'backorders-options' => [
|
167 |
-
'no' => __('No','woocommerce-stock-manager'),
|
168 |
-
'notify' => __('Notify','woocommerce-stock-manager'),
|
169 |
-
'yes' => __('Yes','woocommerce-stock-manager'),
|
170 |
-
],
|
171 |
-
));
|
172 |
-
|
173 |
-
wp_set_script_translations( $this->plugin_slug . '-admin-script-react', 'stock-manager', STOCKDIR . 'languages' );
|
174 |
}
|
175 |
|
176 |
// Klawoo subscribe.
|
@@ -181,31 +190,40 @@ class Stock_Manager_Admin {
|
|
181 |
$params = array(
|
182 |
'ajax_nonce' => wp_create_nonce( 'wsm_update' ),
|
183 |
);
|
184 |
-
wp_localize_script(
|
185 |
-
wp_enqueue_script(
|
186 |
-
|
187 |
}
|
188 |
}
|
189 |
}
|
190 |
|
191 |
-
|
192 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
$menus_positions[] = $key;
|
194 |
}
|
195 |
-
|
196 |
-
if (!in_array($start, $menus_positions))
|
197 |
-
|
|
|
|
|
198 |
/* the position is already reserved find the closet one */
|
199 |
-
while (in_array($start, $menus_positions)) {
|
200 |
$start += $increment;
|
201 |
}
|
|
|
202 |
return $start;
|
203 |
}
|
204 |
|
205 |
/**
|
206 |
* Register the administration menu for this plugin into the WordPress Dashboard menu.
|
207 |
-
*
|
208 |
-
* @since 1.0.0
|
209 |
*/
|
210 |
public function add_plugin_admin_menu() {
|
211 |
|
@@ -213,11 +231,11 @@ class Stock_Manager_Admin {
|
|
213 |
|
214 |
$manage = apply_filters( 'stock_manager_manage', $value );
|
215 |
|
216 |
-
$position = (string) $this->get_free_menu_position(56.00001);
|
217 |
|
218 |
$hook = add_menu_page(
|
219 |
-
__( 'Stock Manager',
|
220 |
-
__( 'Stock Manager',
|
221 |
$manage,
|
222 |
'stock-manager',
|
223 |
array( $this, 'display_plugin_admin_page' ),
|
@@ -225,41 +243,47 @@ class Stock_Manager_Admin {
|
|
225 |
$position
|
226 |
);
|
227 |
|
228 |
-
// Show screen option for React App
|
229 |
-
add_action(
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
add_submenu_page(
|
236 |
'stock-manager',
|
237 |
-
__( 'Import/Export',
|
238 |
-
__( 'Import/Export',
|
239 |
$manage,
|
240 |
'stock-manager-import-export',
|
241 |
array( $this, 'display_import_export_page' )
|
242 |
);
|
243 |
add_submenu_page(
|
244 |
'stock-manager',
|
245 |
-
__( 'Stock log',
|
246 |
-
__( 'Stock log',
|
247 |
$manage,
|
248 |
'stock-manager-log',
|
249 |
array( $this, 'display_log_page' )
|
250 |
);
|
251 |
add_submenu_page(
|
252 |
'stock-manager',
|
253 |
-
__( 'Setting',
|
254 |
-
__( 'Setting',
|
255 |
$manage,
|
256 |
'stock-manager-setting',
|
257 |
array( $this, 'display_setting_page' )
|
258 |
);
|
259 |
add_submenu_page(
|
260 |
'stock-manager',
|
261 |
-
__( 'StoreApps Plugins',
|
262 |
-
__( 'StoreApps Plugins',
|
263 |
$manage,
|
264 |
'stock-manager-storeapps-plugins',
|
265 |
array( $this, 'display_sa_marketplace_page' )
|
@@ -269,57 +293,48 @@ class Stock_Manager_Admin {
|
|
269 |
|
270 |
/**
|
271 |
* Render the settings page for this plugin.
|
272 |
-
*
|
273 |
-
* @since 1.0.0
|
274 |
*/
|
275 |
public function display_plugin_admin_page() {
|
276 |
-
include_once
|
277 |
}
|
|
|
278 |
/**
|
279 |
* Render the impoer export page for this plugin.
|
280 |
-
*
|
281 |
-
* @since 1.0.0
|
282 |
*/
|
283 |
-
|
284 |
public function display_import_export_page() {
|
285 |
-
include_once
|
286 |
}
|
287 |
-
|
288 |
/**
|
289 |
* Render the setting page for this plugin.
|
290 |
-
*
|
291 |
-
* @since 1.2.2
|
292 |
*/
|
293 |
public function display_setting_page() {
|
294 |
-
include_once
|
295 |
}
|
296 |
|
297 |
/**
|
298 |
* Render the StoreApps Marketplace page.
|
299 |
-
*
|
300 |
-
* @since 2.2.0
|
301 |
*/
|
302 |
public function display_sa_marketplace_page() {
|
303 |
-
include_once
|
304 |
WSM_StoreApps_Marketplace::init();
|
305 |
}
|
306 |
|
307 |
/**
|
308 |
* Render the setting page for this plugin.
|
309 |
-
*
|
310 |
-
* @since 2.0.0
|
311 |
*/
|
312 |
public function display_log_page() {
|
313 |
-
if( !empty( $
|
314 |
-
include_once
|
315 |
} else {
|
316 |
-
include_once
|
317 |
}
|
318 |
}
|
319 |
|
320 |
/**
|
321 |
* Function to show SA in app offers in WSM if any.
|
322 |
-
*
|
|
|
323 |
*/
|
324 |
public function may_be_show_sa_in_app_offer() {
|
325 |
if ( ! class_exists( 'SA_In_App_Offers' ) ) {
|
@@ -343,9 +358,9 @@ class Stock_Manager_Admin {
|
|
343 |
* Function to dismiss admin notice.
|
344 |
*/
|
345 |
public function wsm_dismiss_admin_notice() {
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
update_option( $option_name . '_wsm', 'no', 'no' );
|
350 |
$referer = wp_get_referer();
|
351 |
wp_safe_redirect( $referer );
|
@@ -455,7 +470,7 @@ class Stock_Manager_Admin {
|
|
455 |
$is_wsm_admin = $this->is_wsm_admin_page();
|
456 |
if ( $is_wsm_admin ) {
|
457 |
/* translators: %1$s & %2$s: Opening & closing strong tag. %3$s: link to Stock Manager for WooCommerce on WordPress.org */
|
458 |
-
$wsm_rating_text = sprintf( __( 'If you are liking %1$
|
459 |
}
|
460 |
|
461 |
return $wsm_rating_text;
|
@@ -472,7 +487,7 @@ class Stock_Manager_Admin {
|
|
472 |
|
473 |
$is_wsm_admin = $this->is_wsm_admin_page();
|
474 |
if ( $is_wsm_admin ) {
|
475 |
-
$wsm_text = 'Installed Version: '. WSM_PLUGIN_VERSION;
|
476 |
?>
|
477 |
<style type="text/css">
|
478 |
#wpfooter {
|
@@ -489,4 +504,4 @@ class Stock_Manager_Admin {
|
|
489 |
|
490 |
}
|
491 |
|
492 |
-
}//
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Main class for Stock Manager.
|
4 |
+
*
|
5 |
* @package woocommerce-stock-manager/admin/
|
6 |
+
* @version 2.8.0
|
7 |
*/
|
8 |
|
9 |
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
exit;
|
11 |
}
|
12 |
|
13 |
+
/**
|
14 |
+
* Class for Stock Manager Admin.
|
15 |
+
*/
|
16 |
class Stock_Manager_Admin {
|
17 |
|
18 |
/**
|
19 |
* Instance of this class.
|
20 |
*
|
|
|
|
|
21 |
* @var object
|
22 |
*/
|
23 |
protected static $instance = null;
|
24 |
|
25 |
/**
|
26 |
+
* Initialize the plugin by loading admin scripts & styles and adding a settings page and menu.
|
|
|
|
|
|
|
27 |
*/
|
28 |
private function __construct() {
|
29 |
|
30 |
+
// Set page.
|
31 |
+
$this->page = ( ! empty( $_GET['page'] ) ) ? wc_clean( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore
|
32 |
+
|
33 |
+
// For stock log history page.
|
34 |
+
$this->product_id = ( ! empty( $_GET['product-history'] ) ) ? wc_clean( wp_unslash( $_GET['product-history'] ) ) : 0; // phpcs:ignore
|
35 |
|
36 |
// Load admin style sheet and JavaScript.
|
37 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
|
39 |
|
40 |
// Add the options page and menu item.
|
41 |
add_action( 'admin_menu', array( $this, 'add_plugin_admin_menu' ) );
|
42 |
+
|
43 |
+
include_once 'includes/class-wsm-stock.php';
|
44 |
+
|
45 |
add_action( 'admin_notices', array( $this, 'includes' ) );
|
46 |
|
47 |
add_action( 'admin_init', array( $this, 'wsm_dismiss_admin_notice' ) );
|
54 |
/**
|
55 |
* Return an instance of this class.
|
56 |
*
|
|
|
|
|
57 |
* @return object A single instance of this class.
|
58 |
*/
|
59 |
public static function get_instance() {
|
60 |
|
61 |
// If the single instance hasn't been set, set it now.
|
62 |
+
if ( is_null( self::$instance ) ) {
|
63 |
+
self::$instance = new self();
|
64 |
}
|
65 |
|
66 |
return self::$instance;
|
67 |
}
|
68 |
+
|
69 |
/**
|
70 |
* Include required core files used in admin.
|
|
|
|
|
71 |
*/
|
72 |
public function includes() {
|
73 |
$is_wsm_admin = $this->is_wsm_admin_page();
|
74 |
if ( $is_wsm_admin ) {
|
75 |
$this->may_be_show_sa_in_app_offer();
|
76 |
$this->wsm_add_subscribe_notice();
|
77 |
+
|
78 |
}
|
79 |
}
|
80 |
|
82 |
* Function to check if WSM admin page.
|
83 |
*/
|
84 |
public function is_wsm_admin_page() {
|
85 |
+
if ( 'stock-manager' === $this->page || 'stock-manager-import-export' === $this->page || 'stock-manager-log' === $this->page || 'stock-manager-setting' === $this->page || 'stock-manager-storeapps-plugins' === $this->page ) {
|
86 |
+
return true;
|
|
|
|
|
87 |
}
|
88 |
|
89 |
return false;
|
91 |
|
92 |
/**
|
93 |
* Get stock class
|
94 |
+
*
|
95 |
+
* @return WSM_Stock
|
|
|
96 |
*/
|
97 |
public function stock() {
|
98 |
+
return WSM_Stock::get_instance();
|
99 |
}
|
100 |
|
101 |
/**
|
102 |
* Register and enqueue admin-specific CSS.
|
|
|
|
|
|
|
103 |
*/
|
104 |
public function enqueue_admin_styles() {
|
105 |
+
if ( ( 'stock-manager' === $this->page || 'stock-manager-import-export' === $this->page || 'stock-manager-log' === $this->page ) ) {
|
106 |
+
wp_enqueue_style( 'woocommerce-stock-manager-admin-styles', plugins_url( 'assets/css/admin.css', __FILE__ ), array(), WSM_PLUGIN_VERSION );
|
107 |
|
108 |
$old_styles = get_option( 'woocommerce_stock_old_styles' );
|
109 |
+
if ( ! empty( $old_styles ) && 'ok' === $old_styles ) {
|
110 |
+
wp_enqueue_style( 'woocommerce-stock-manager-old-styles', plugins_url( 'assets/css/old.css', __FILE__ ), array(), WSM_PLUGIN_VERSION );
|
111 |
}
|
112 |
}
|
113 |
}
|
114 |
|
115 |
/**
|
116 |
* Register and enqueue admin-specific JavaScript.
|
|
|
|
|
|
|
117 |
*/
|
118 |
public function enqueue_admin_scripts() {
|
119 |
+
if ( ( 'stock-manager' === $this->page || 'stock-manager-import-export' === $this->page ) ) {
|
120 |
$low_stock_threshold = get_option( 'woocommerce_notify_low_stock_amount', 5 );
|
121 |
$low_stock_threshold = ( ! empty( $low_stock_threshold ) ) ? $low_stock_threshold : 5;
|
122 |
|
123 |
+
wp_enqueue_style( 'woocommerce-stock-manager-admin-script-react', plugins_url( 'assets/build/index.css', __FILE__ ), array(), WSM_PLUGIN_VERSION );
|
124 |
+
wp_enqueue_script( 'woocommerce-stock-manager-admin-script-react', plugins_url( 'assets/build/index.js', __FILE__ ), array( 'wp-polyfill', 'wp-i18n', 'wp-url' ), WSM_PLUGIN_VERSION, true );
|
125 |
+
wp_localize_script(
|
126 |
+
'woocommerce-stock-manager-admin-script-react',
|
127 |
+
'WooCommerceStockManagerPreloadedState',
|
128 |
+
array(
|
129 |
+
'app' => array(
|
130 |
+
'textDomain' => 'woocommerce-stock-manager',
|
131 |
+
'root' => esc_url_raw( rest_url() ),
|
132 |
+
'adminUrl' => admin_url(),
|
133 |
+
'nonce' => wp_create_nonce( 'wp_rest' ),
|
134 |
+
'perPage' => apply_filters( 'woocommerce_stock_manager_per_page', 50 ),
|
135 |
+
'lowStockThreshold' => $low_stock_threshold,
|
136 |
+
),
|
137 |
+
'product-categories' => array_reduce(
|
138 |
+
get_terms(
|
139 |
+
array(
|
140 |
+
'taxonomy' => 'product_cat',
|
141 |
+
'hide_empty' => false,
|
142 |
+
)
|
143 |
+
),
|
144 |
+
function( $carry, $item ) {
|
145 |
+
$carry[ $item->term_id ] = $item->name;
|
146 |
+
return $carry;
|
147 |
+
},
|
148 |
+
array()
|
149 |
+
),
|
150 |
+
'product-types' => wc_get_product_types(),
|
151 |
+
'stock-status-options' => wc_get_product_stock_status_options(),
|
152 |
+
'shipping-classes' => array_merge(
|
153 |
+
array( '' => __( 'No shipping class', 'woocommerce-stock-manager' ) ),
|
154 |
+
array_reduce(
|
155 |
+
get_terms(
|
156 |
+
array(
|
157 |
+
'taxonomy' => 'product_shipping_class',
|
158 |
+
'hide_empty' => false,
|
159 |
+
)
|
160 |
+
),
|
161 |
+
function( $carry, $item ) {
|
162 |
+
$carry[ $item->slug ] = $item->name;
|
163 |
+
return $carry;
|
164 |
+
},
|
165 |
+
array()
|
166 |
+
)
|
167 |
+
),
|
168 |
+
'tax-classes' => wc_get_product_tax_class_options(),
|
169 |
+
'tax-statuses' => array(
|
170 |
+
'taxable' => __( 'Taxable', 'woocommerce-stock-manager' ),
|
171 |
+
'shipping' => __( 'Shipping only', 'woocommerce-stock-manager' ),
|
172 |
+
'none' => _x( 'None', 'Tax status', 'woocommerce-stock-manager' ),
|
173 |
+
),
|
174 |
+
'backorders-options' => array(
|
175 |
+
'no' => __( 'No', 'woocommerce-stock-manager' ),
|
176 |
+
'notify' => __( 'Notify', 'woocommerce-stock-manager' ),
|
177 |
+
'yes' => __( 'Yes', 'woocommerce-stock-manager' ),
|
178 |
+
),
|
179 |
+
)
|
180 |
);
|
181 |
+
|
182 |
+
wp_set_script_translations( 'woocommerce-stock-manager-admin-script-react', 'stock-manager', STOCKDIR . 'languages' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
}
|
184 |
|
185 |
// Klawoo subscribe.
|
190 |
$params = array(
|
191 |
'ajax_nonce' => wp_create_nonce( 'wsm_update' ),
|
192 |
);
|
193 |
+
wp_localize_script( 'woocommerce-stock-manager-admin-script-w', 'ajax_object', $params );
|
194 |
+
wp_enqueue_script( 'woocommerce-stock-manager-admin-script-w', plugins_url( 'assets/js/subscribe.js', __FILE__ ), array( 'jquery' ), WSM_PLUGIN_VERSION, true );
|
195 |
+
|
196 |
}
|
197 |
}
|
198 |
}
|
199 |
|
200 |
+
/**
|
201 |
+
* Function to get menu position for Stock Manager.
|
202 |
+
*
|
203 |
+
* @param double $start Starting position.
|
204 |
+
* @param double $increment Increment by.
|
205 |
+
*
|
206 |
+
* @return double Final menu position.
|
207 |
+
*/
|
208 |
+
public function get_free_menu_position( $start, $increment = 0.0001 ) {
|
209 |
+
foreach ( $GLOBALS['menu'] as $key => $menu ) {
|
210 |
$menus_positions[] = $key;
|
211 |
}
|
212 |
+
|
213 |
+
if ( ! in_array( $start, $menus_positions, true ) ) {
|
214 |
+
return $start;
|
215 |
+
}
|
216 |
+
|
217 |
/* the position is already reserved find the closet one */
|
218 |
+
while ( in_array( $start, $menus_positions, true ) ) {
|
219 |
$start += $increment;
|
220 |
}
|
221 |
+
|
222 |
return $start;
|
223 |
}
|
224 |
|
225 |
/**
|
226 |
* Register the administration menu for this plugin into the WordPress Dashboard menu.
|
|
|
|
|
227 |
*/
|
228 |
public function add_plugin_admin_menu() {
|
229 |
|
231 |
|
232 |
$manage = apply_filters( 'stock_manager_manage', $value );
|
233 |
|
234 |
+
$position = (string) $this->get_free_menu_position( 56.00001 );
|
235 |
|
236 |
$hook = add_menu_page(
|
237 |
+
__( 'Stock Manager', 'woocommerce-stock-manager' ),
|
238 |
+
__( 'Stock Manager', 'woocommerce-stock-manager' ),
|
239 |
$manage,
|
240 |
'stock-manager',
|
241 |
array( $this, 'display_plugin_admin_page' ),
|
243 |
$position
|
244 |
);
|
245 |
|
246 |
+
// Show screen option for React App.
|
247 |
+
add_action(
|
248 |
+
'load-' . $hook,
|
249 |
+
function() {
|
250 |
+
add_filter(
|
251 |
+
'screen_options_show_screen',
|
252 |
+
function () {
|
253 |
+
return true;
|
254 |
+
}
|
255 |
+
);
|
256 |
+
}
|
257 |
+
);
|
258 |
+
|
259 |
add_submenu_page(
|
260 |
'stock-manager',
|
261 |
+
__( 'Import/Export', 'woocommerce-stock-manager' ),
|
262 |
+
__( 'Import/Export', 'woocommerce-stock-manager' ),
|
263 |
$manage,
|
264 |
'stock-manager-import-export',
|
265 |
array( $this, 'display_import_export_page' )
|
266 |
);
|
267 |
add_submenu_page(
|
268 |
'stock-manager',
|
269 |
+
__( 'Stock log', 'woocommerce-stock-manager' ),
|
270 |
+
__( 'Stock log', 'woocommerce-stock-manager' ),
|
271 |
$manage,
|
272 |
'stock-manager-log',
|
273 |
array( $this, 'display_log_page' )
|
274 |
);
|
275 |
add_submenu_page(
|
276 |
'stock-manager',
|
277 |
+
__( 'Stock Manager Setting', 'woocommerce-stock-manager' ),
|
278 |
+
__( 'Setting', 'woocommerce-stock-manager' ),
|
279 |
$manage,
|
280 |
'stock-manager-setting',
|
281 |
array( $this, 'display_setting_page' )
|
282 |
);
|
283 |
add_submenu_page(
|
284 |
'stock-manager',
|
285 |
+
__( 'StoreApps Plugins', 'woocommerce-stock-manager' ),
|
286 |
+
__( 'StoreApps Plugins', 'woocommerce-stock-manager' ),
|
287 |
$manage,
|
288 |
'stock-manager-storeapps-plugins',
|
289 |
array( $this, 'display_sa_marketplace_page' )
|
293 |
|
294 |
/**
|
295 |
* Render the settings page for this plugin.
|
|
|
|
|
296 |
*/
|
297 |
public function display_plugin_admin_page() {
|
298 |
+
include_once 'views/admin.php';
|
299 |
}
|
300 |
+
|
301 |
/**
|
302 |
* Render the impoer export page for this plugin.
|
|
|
|
|
303 |
*/
|
|
|
304 |
public function display_import_export_page() {
|
305 |
+
include_once 'views/import-export.php';
|
306 |
}
|
307 |
+
|
308 |
/**
|
309 |
* Render the setting page for this plugin.
|
|
|
|
|
310 |
*/
|
311 |
public function display_setting_page() {
|
312 |
+
include_once 'views/setting.php';
|
313 |
}
|
314 |
|
315 |
/**
|
316 |
* Render the StoreApps Marketplace page.
|
|
|
|
|
317 |
*/
|
318 |
public function display_sa_marketplace_page() {
|
319 |
+
include_once 'views/class-wsm-storeapps-marketplace.php';
|
320 |
WSM_StoreApps_Marketplace::init();
|
321 |
}
|
322 |
|
323 |
/**
|
324 |
* Render the setting page for this plugin.
|
|
|
|
|
325 |
*/
|
326 |
public function display_log_page() {
|
327 |
+
if ( ! empty( $this->product_id ) ) { // If found, we are on stock log history page.
|
328 |
+
include_once 'views/log-history.php';
|
329 |
} else {
|
330 |
+
include_once 'views/log.php';
|
331 |
}
|
332 |
}
|
333 |
|
334 |
/**
|
335 |
* Function to show SA in app offers in WSM if any.
|
336 |
+
*
|
337 |
+
* @since: 2.5.2.
|
338 |
*/
|
339 |
public function may_be_show_sa_in_app_offer() {
|
340 |
if ( ! class_exists( 'SA_In_App_Offers' ) ) {
|
358 |
* Function to dismiss admin notice.
|
359 |
*/
|
360 |
public function wsm_dismiss_admin_notice() {
|
361 |
+
$dismiss_wsm_notice = ( ! empty( $_GET['wsm_dismiss_admin_notice'] ) ) ? wc_clean( wp_unslash( $_GET['wsm_dismiss_admin_notice'] ) ) : ''; // phpcs:ignore
|
362 |
+
$option_name = ( ! empty( $_GET['option_name'] ) ) ? wc_clean( wp_unslash( $_GET['option_name'] ) ) : ''; // phpcs:ignore
|
363 |
+
if ( '1' === $dismiss_wsm_notice && $option_name ) {
|
364 |
update_option( $option_name . '_wsm', 'no', 'no' );
|
365 |
$referer = wp_get_referer();
|
366 |
wp_safe_redirect( $referer );
|
470 |
$is_wsm_admin = $this->is_wsm_admin_page();
|
471 |
if ( $is_wsm_admin ) {
|
472 |
/* translators: %1$s & %2$s: Opening & closing strong tag. %3$s: link to Stock Manager for WooCommerce on WordPress.org */
|
473 |
+
$wsm_rating_text = sprintf( __( 'If you are liking %1$sStock Manager for WooCommerce%2$s, please rate us %3$s. A huge thanks from StoreApps in advance!', 'woocommerce-stock-manager' ), '<strong>', '</strong>', '<a target="_blank" href="' . esc_url( 'https://wordpress.org/support/plugin/woocommerce-stock-manager/reviews/?filter=5' ) . '" style="color: #5850EC;">5-star</a>' );
|
474 |
}
|
475 |
|
476 |
return $wsm_rating_text;
|
487 |
|
488 |
$is_wsm_admin = $this->is_wsm_admin_page();
|
489 |
if ( $is_wsm_admin ) {
|
490 |
+
$wsm_text = 'Installed Version: ' . WSM_PLUGIN_VERSION;
|
491 |
?>
|
492 |
<style type="text/css">
|
493 |
#wpfooter {
|
504 |
|
505 |
}
|
506 |
|
507 |
+
}//end class
|
admin/includes/{wcm-class-save.php → class-wsm-save.php}
RENAMED
@@ -1,42 +1,31 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Save class
|
4 |
*
|
5 |
* @package woocommerce-stock-manager/admin/includes/
|
6 |
-
* @version 2.
|
7 |
*/
|
8 |
|
9 |
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
exit;
|
11 |
}
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
*
|
18 |
-
* @since 1.2.2
|
19 |
-
*/
|
20 |
-
public static function save_one( $data, $product_id ) {
|
21 |
-
|
22 |
-
$values = self::prepare_one_data( $data );
|
23 |
-
|
24 |
-
if( !empty( $values ) ) {
|
25 |
-
self::save_data( $values, $product_id );
|
26 |
-
}
|
27 |
-
|
28 |
-
}
|
29 |
|
30 |
/**
|
31 |
* Save data for one item (used in foreach, for save all button)
|
32 |
*
|
33 |
-
* @
|
|
|
34 |
*/
|
35 |
public static function save_one_item( $data, $product_id ) {
|
36 |
|
37 |
$values = self::prepare_data( $data, $product_id );
|
38 |
|
39 |
-
if( !empty( $values ) ) {
|
40 |
self::save_data( $values, $product_id );
|
41 |
}
|
42 |
|
@@ -45,46 +34,21 @@ class WCM_Save {
|
|
45 |
/**
|
46 |
* Prepare data
|
47 |
*
|
48 |
-
* @
|
49 |
-
|
50 |
-
public static function prepare_data( $data, $item ){
|
51 |
-
|
52 |
-
$values = array();
|
53 |
-
$defaults = self::get_default();
|
54 |
-
|
55 |
-
foreach( $defaults as $default ){
|
56 |
-
|
57 |
-
if( isset( $data[$default] ) ) {
|
58 |
-
|
59 |
-
$values[$default] = sanitize_text_field( $data[$default] );
|
60 |
-
|
61 |
-
}
|
62 |
-
|
63 |
-
}
|
64 |
-
|
65 |
-
return $values;
|
66 |
-
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Prepare one data
|
71 |
-
*
|
72 |
-
* @since 1.2.2
|
73 |
*/
|
74 |
-
public static function
|
75 |
-
|
76 |
-
$values = array();
|
77 |
|
|
|
78 |
$defaults = self::get_default();
|
79 |
|
80 |
-
foreach( $defaults as $default ){
|
81 |
|
82 |
-
if( isset( $data[$default] ) ) {
|
83 |
|
84 |
-
$values[$default]
|
85 |
|
86 |
}
|
87 |
-
|
88 |
}
|
89 |
|
90 |
return $values;
|
@@ -92,11 +56,9 @@ class WCM_Save {
|
|
92 |
}
|
93 |
|
94 |
/**
|
95 |
-
* Get
|
96 |
-
*
|
97 |
-
* @since 1.2.2
|
98 |
*/
|
99 |
-
public static function get_default(){
|
100 |
|
101 |
$values = array(
|
102 |
'sku',
|
@@ -117,55 +79,58 @@ class WCM_Save {
|
|
117 |
}
|
118 |
|
119 |
/**
|
120 |
-
* Save data
|
121 |
*
|
122 |
-
* @
|
|
|
123 |
*/
|
124 |
public static function save_data( $data, $product_id ) {
|
125 |
|
126 |
$display_option = get_option( 'wsm_display_option' );
|
127 |
|
128 |
$_product = wc_get_product( $product_id );
|
|
|
129 |
// use is_a instead of instanceof to cover all product types.
|
130 |
if ( is_a( $_product, 'WC_Product' ) ) {
|
131 |
|
132 |
-
if( isset( $data['sku'] ) ) {
|
133 |
$_product->set_sku( $data['sku'] );
|
134 |
}
|
135 |
-
|
136 |
-
if( isset( $data['manage_stock'] ) ) {
|
137 |
$_product->set_manage_stock( $data['manage_stock'] );
|
138 |
}
|
139 |
|
140 |
-
if( isset( $data['backorders'] ) ) {
|
141 |
$_product->set_backorders( $data['backorders'] );
|
142 |
}
|
143 |
|
144 |
-
if( isset( $data['stock_status'] ) ) {
|
145 |
$_product->set_stock_status( $data['stock_status'] );
|
146 |
}
|
147 |
-
|
148 |
-
if( isset( $data['stock'] ) ) {
|
149 |
$_product->set_stock_quantity( $data['stock'] );
|
150 |
}
|
151 |
-
|
152 |
-
if( isset( $data['tax_status'] ) ) {
|
153 |
$_product->set_tax_status( $data['tax_status'] );
|
154 |
}
|
155 |
-
|
156 |
-
if( isset( $data['tax_class'] ) ) {
|
157 |
$_product->set_tax_class( $data['tax_class'] );
|
158 |
}
|
159 |
-
|
160 |
-
if( isset( $data['shipping_class'] ) ) {
|
161 |
$_product->set_shipping_class_id( $data['shipping_class'] );
|
162 |
}
|
163 |
-
|
164 |
-
if( isset( $data['weight'] ) ){
|
165 |
$_product->set_weight( $data['weight'] );
|
166 |
}
|
167 |
-
|
168 |
-
|
|
|
169 |
$price = sanitize_text_field($data['regular_price']);
|
170 |
if( !empty( $data['sales_price'] ) ){
|
171 |
$sale_price = sanitize_text_field($data['sales_price']);
|
@@ -173,27 +138,26 @@ class WCM_Save {
|
|
173 |
}else{
|
174 |
wsm_save_price( $product_id, $price );
|
175 |
}
|
176 |
-
}
|
177 |
-
*/
|
178 |
-
if( isset( $data['regular_price'] ) ) {
|
179 |
-
if( !empty( $data['regular_price'] ) ){
|
180 |
-
$_product->set_price( $data['regular_price'] );
|
181 |
-
$_product->set_regular_price( $data['regular_price'] );
|
182 |
}
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
184 |
$_product->set_price( '' );
|
185 |
$_product->set_regular_price( '' );
|
186 |
}
|
187 |
-
}
|
188 |
-
|
189 |
-
if( isset( $data['sales_price'] ) ) {
|
190 |
-
if( !empty( $data['sales_price'] ) ){
|
191 |
$_product->set_sale_price( $data['sales_price'] );
|
192 |
} else {
|
193 |
$_product->set_sale_price( '' );
|
194 |
}
|
195 |
-
}
|
196 |
-
|
197 |
$_product->save();
|
198 |
|
199 |
wc_delete_product_transients( $product_id );
|
@@ -202,4 +166,4 @@ class WCM_Save {
|
|
202 |
|
203 |
}
|
204 |
|
205 |
-
}//
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Save class for data via import.
|
4 |
*
|
5 |
* @package woocommerce-stock-manager/admin/includes/
|
6 |
+
* @version 2.8.0
|
7 |
*/
|
8 |
|
9 |
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
exit;
|
11 |
}
|
12 |
|
13 |
+
/**
|
14 |
+
* Class for saving changes done via Stock Manager Import.
|
15 |
+
*/
|
16 |
+
class WSM_Save {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
/**
|
19 |
* Save data for one item (used in foreach, for save all button)
|
20 |
*
|
21 |
+
* @param array $data The column key to name map.
|
22 |
+
* @param ID $product_id The ID of the product.
|
23 |
*/
|
24 |
public static function save_one_item( $data, $product_id ) {
|
25 |
|
26 |
$values = self::prepare_data( $data, $product_id );
|
27 |
|
28 |
+
if ( ! empty( $values ) ) {
|
29 |
self::save_data( $values, $product_id );
|
30 |
}
|
31 |
|
34 |
/**
|
35 |
* Prepare data
|
36 |
*
|
37 |
+
* @param array $data The column key to name map.
|
38 |
+
* @param string $item ID.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
*/
|
40 |
+
public static function prepare_data( $data, $item ) {
|
|
|
|
|
41 |
|
42 |
+
$values = array();
|
43 |
$defaults = self::get_default();
|
44 |
|
45 |
+
foreach ( $defaults as $default ) {
|
46 |
|
47 |
+
if ( isset( $data[ $default ] ) ) {
|
48 |
|
49 |
+
$values[ $default ] = wc_clean( $data[ $default ] );
|
50 |
|
51 |
}
|
|
|
52 |
}
|
53 |
|
54 |
return $values;
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
+
* Get defaults.
|
|
|
|
|
60 |
*/
|
61 |
+
public static function get_default() {
|
62 |
|
63 |
$values = array(
|
64 |
'sku',
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
+
* Save prepared data.
|
83 |
*
|
84 |
+
* @param array $data The column key to name map.
|
85 |
+
* @param ID $product_id The ID of the product.
|
86 |
*/
|
87 |
public static function save_data( $data, $product_id ) {
|
88 |
|
89 |
$display_option = get_option( 'wsm_display_option' );
|
90 |
|
91 |
$_product = wc_get_product( $product_id );
|
92 |
+
|
93 |
// use is_a instead of instanceof to cover all product types.
|
94 |
if ( is_a( $_product, 'WC_Product' ) ) {
|
95 |
|
96 |
+
if ( isset( $data['sku'] ) ) {
|
97 |
$_product->set_sku( $data['sku'] );
|
98 |
}
|
99 |
+
|
100 |
+
if ( isset( $data['manage_stock'] ) ) {
|
101 |
$_product->set_manage_stock( $data['manage_stock'] );
|
102 |
}
|
103 |
|
104 |
+
if ( isset( $data['backorders'] ) ) {
|
105 |
$_product->set_backorders( $data['backorders'] );
|
106 |
}
|
107 |
|
108 |
+
if ( isset( $data['stock_status'] ) ) {
|
109 |
$_product->set_stock_status( $data['stock_status'] );
|
110 |
}
|
111 |
+
|
112 |
+
if ( isset( $data['stock'] ) ) {
|
113 |
$_product->set_stock_quantity( $data['stock'] );
|
114 |
}
|
115 |
+
|
116 |
+
if ( isset( $data['tax_status'] ) ) {
|
117 |
$_product->set_tax_status( $data['tax_status'] );
|
118 |
}
|
119 |
+
|
120 |
+
if ( isset( $data['tax_class'] ) ) {
|
121 |
$_product->set_tax_class( $data['tax_class'] );
|
122 |
}
|
123 |
+
|
124 |
+
if ( isset( $data['shipping_class'] ) ) {
|
125 |
$_product->set_shipping_class_id( $data['shipping_class'] );
|
126 |
}
|
127 |
+
|
128 |
+
if ( isset( $data['weight'] ) ) {
|
129 |
$_product->set_weight( $data['weight'] );
|
130 |
}
|
131 |
+
|
132 |
+
/* // @codingStandardsIgnoreLine
|
133 |
+
if( !empty( $data['regular_price'] ) ){
|
134 |
$price = sanitize_text_field($data['regular_price']);
|
135 |
if( !empty( $data['sales_price'] ) ){
|
136 |
$sale_price = sanitize_text_field($data['sales_price']);
|
138 |
}else{
|
139 |
wsm_save_price( $product_id, $price );
|
140 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
}
|
142 |
+
*/
|
143 |
+
if ( isset( $data['regular_price'] ) ) {
|
144 |
+
if ( ! empty( $data['regular_price'] ) ) {
|
145 |
+
$_product->set_price( $data['regular_price'] );
|
146 |
+
$_product->set_regular_price( $data['regular_price'] );
|
147 |
+
} else {
|
148 |
$_product->set_price( '' );
|
149 |
$_product->set_regular_price( '' );
|
150 |
}
|
151 |
+
}
|
152 |
+
|
153 |
+
if ( isset( $data['sales_price'] ) ) {
|
154 |
+
if ( ! empty( $data['sales_price'] ) ) {
|
155 |
$_product->set_sale_price( $data['sales_price'] );
|
156 |
} else {
|
157 |
$_product->set_sale_price( '' );
|
158 |
}
|
159 |
+
}
|
160 |
+
|
161 |
$_product->save();
|
162 |
|
163 |
wc_delete_product_transients( $product_id );
|
166 |
|
167 |
}
|
168 |
|
169 |
+
}//end class
|
admin/includes/class-wsm-stock.php
ADDED
@@ -0,0 +1,325 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Stock Log Class
|
4 |
+
*
|
5 |
+
* @package woocommerce-stock-manager/admin/includes/
|
6 |
+
* @version 2.8.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
+
exit;
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Class for Stock Log Manager.
|
15 |
+
*/
|
16 |
+
class WSM_Stock {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Instance of this class.
|
20 |
+
*
|
21 |
+
* @var object
|
22 |
+
*/
|
23 |
+
protected static $instance = null;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Constructor for the stock class.
|
27 |
+
*
|
28 |
+
* @var string
|
29 |
+
*/
|
30 |
+
public $limit = 100;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Constructor for the stock class.
|
34 |
+
*/
|
35 |
+
private function __construct() {
|
36 |
+
|
37 |
+
$limit = get_option( 'woocommerce_stock_limit' );
|
38 |
+
if ( ! empty( $limit ) ) {
|
39 |
+
$this->limit = $limit;
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Return an instance of this class.
|
46 |
+
*
|
47 |
+
* @return object A single instance of this class.
|
48 |
+
*/
|
49 |
+
public static function get_instance() {
|
50 |
+
|
51 |
+
// If the single instance hasn't been set, set it now.
|
52 |
+
if ( is_null( self::$instance ) ) {
|
53 |
+
self::$instance = new self();
|
54 |
+
}
|
55 |
+
|
56 |
+
return self::$instance;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Return products
|
61 |
+
*
|
62 |
+
* @param array $data The products data.
|
63 |
+
*/
|
64 |
+
public function get_products( $data = array() ) {
|
65 |
+
|
66 |
+
$get_sku = ( ! empty( $_GET['sku'] ) ) ? wc_clean( wp_unslash( $_GET['sku'] ) ) : ''; // phpcs:ignore
|
67 |
+
if ( ! empty( $get_sku ) ) {
|
68 |
+
return $this->get_product_by_sku( $get_sku );
|
69 |
+
}
|
70 |
+
|
71 |
+
$get_product_title = ( ! empty( $_GET['product-title'] ) ) ? wc_clean( wp_unslash( $_GET['product-title'] ) ) : ''; // phpcs:ignore
|
72 |
+
if ( ! empty( $get_product_title ) ) {
|
73 |
+
return $this->get_product_by_product_title( $get_product_title );
|
74 |
+
}
|
75 |
+
|
76 |
+
$args = array();
|
77 |
+
$args['post_type'] = 'product';
|
78 |
+
|
79 |
+
$get_product_type = ( ! empty( $_GET['product-type'] ) ) ? wc_clean( wp_unslash( $_GET['product-type'] ) ) : ''; // phpcs:ignore
|
80 |
+
$get_product_category = ( ! empty( $_GET['product-category'] ) ) ? wc_clean( wp_unslash( $_GET['product-category'] ) ) : ''; // phpcs:ignore
|
81 |
+
// Initialize tax_query array.
|
82 |
+
if ( ! empty( $get_product_type ) || ! empty( $get_product_category ) ) {
|
83 |
+
$args['tax_query'] = array(); // phpcs:ignore
|
84 |
+
|
85 |
+
if ( ! empty( $get_product_type ) ) {
|
86 |
+
if ( 'variable' === $get_product_type ) {
|
87 |
+
$args['tax_query'][] = array(
|
88 |
+
'taxonomy' => 'product_type',
|
89 |
+
'terms' => 'variable',
|
90 |
+
'field' => 'slug',
|
91 |
+
);
|
92 |
+
} else {
|
93 |
+
$args['tax_query'] = array( // phpcs:ignore
|
94 |
+
'taxonomy' => 'product_type',
|
95 |
+
'terms' => 'simple',
|
96 |
+
'field' => 'slug',
|
97 |
+
);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Product category filter.
|
103 |
+
*/
|
104 |
+
if ( ! empty( $get_product_category ) ) {
|
105 |
+
if ( 'all' !== $get_product_category ) {
|
106 |
+
$category = $get_product_category;
|
107 |
+
$args['tax_query'][] = array(
|
108 |
+
'taxonomy' => 'product_cat',
|
109 |
+
'terms' => $category,
|
110 |
+
'field' => 'term_id',
|
111 |
+
);
|
112 |
+
}
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
$get_stock_status = ( ! empty( $_GET['stock-status'] ) ) ? wc_clean( wp_unslash( $_GET['stock-status'] ) ) : ''; // phpcs:ignore
|
117 |
+
$get_manage_stock = ( ! empty( $_GET['manage-stock'] ) ) ? wc_clean( wp_unslash( $_GET['manage-stock'] ) ) : ''; // phpcs:ignore
|
118 |
+
// Initialize meta_query array.
|
119 |
+
if ( ! empty( $get_stock_status ) || ! empty( $get_manage_stock ) ) {
|
120 |
+
$args['meta_query'] = array(); // phpcs:ignore
|
121 |
+
|
122 |
+
if ( ! empty( $get_stock_status ) ) {
|
123 |
+
$args['meta_query'][] = array(
|
124 |
+
'key' => '_stock_status',
|
125 |
+
'value' => $get_stock_status,
|
126 |
+
'compare' => '=',
|
127 |
+
);
|
128 |
+
}
|
129 |
+
|
130 |
+
if ( ! empty( $get_manage_stock ) ) {
|
131 |
+
$args['meta_query'][] = array(
|
132 |
+
'key' => '_manage_stock',
|
133 |
+
'value' => $get_manage_stock,
|
134 |
+
'compare' => '=',
|
135 |
+
);
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
$get_order_by = ( ! empty( $_GET['order-by'] ) ) ? wc_clean( wp_unslash( $_GET['order-by'] ) ) : ''; // phpcs:ignore
|
140 |
+
if ( ! empty( $get_order_by ) ) {
|
141 |
+
if ( 'name-asc' === $get_order_by ) {
|
142 |
+
$args['orderby'] = 'title';
|
143 |
+
$args['order'] = 'ASC';
|
144 |
+
} elseif ( 'name-desc' === $get_order_by ) {
|
145 |
+
$args['orderby'] = 'title';
|
146 |
+
$args['order'] = 'DESC';
|
147 |
+
} elseif ( 'sku-asc' === $get_order_by ) {
|
148 |
+
$args['meta_key'] = '_sku'; // phpcs:ignore
|
149 |
+
$args['orderby'] = 'meta_value';
|
150 |
+
$args['order'] = 'ASC';
|
151 |
+
} elseif ( 'sku-desc' === $get_order_by ) {
|
152 |
+
$args['meta_key'] = '_sku'; // phpcs:ignore
|
153 |
+
$args['orderby'] = 'meta_value';
|
154 |
+
$args['order'] = 'DESC';
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
$args['posts_per_page'] = $this->limit;
|
159 |
+
|
160 |
+
$passed_offset = ( ! empty( $_GET['offset'] ) ) ? wc_clean( wp_unslash( $_GET['offset'] ) ) : 0; // phpcs:ignore
|
161 |
+
|
162 |
+
$args['offset'] = ( ! empty( $passed_offset ) ) ? ( ( intval( $passed_offset ) - 1 ) * $this->limit ) : $passed_offset;
|
163 |
+
|
164 |
+
$the_query = new WP_Query( $args );
|
165 |
+
|
166 |
+
return $the_query;
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Return pagination
|
171 |
+
*
|
172 |
+
* @param string $query The query.
|
173 |
+
*/
|
174 |
+
public function pagination( $query ) {
|
175 |
+
|
176 |
+
$get_sku = ( ! empty( $_GET['sku'] ) ) ? wc_clean( wp_unslash( $_GET['sku'] ) ) : ''; // phpcs:ignore
|
177 |
+
if ( empty( $get_sku ) ) {
|
178 |
+
return false;
|
179 |
+
}
|
180 |
+
|
181 |
+
$all = $query->found_posts;
|
182 |
+
|
183 |
+
$pages = ceil( $all / $this->limit );
|
184 |
+
$passed_offset = ( ! empty( $_GET['offset'] ) ) ? wc_clean( wp_unslash( $_GET['offset'] ) ) : 0; // phpcs:ignore
|
185 |
+
$current = ( ! empty( $passed_offset ) ) ? intval( $passed_offset ) : 1;
|
186 |
+
|
187 |
+
$html = '';
|
188 |
+
$html .= '<div class="stock-manager-pagination">';
|
189 |
+
$query_string = ( ! empty( $_SERVER['QUERY_STRING'] ) ) ? wc_clean( wp_unslash( $_SERVER['QUERY_STRING'] ) ) : ''; // phpcs:ignore
|
190 |
+
if ( 1 !== $pages ) {
|
191 |
+
for ( $i = 1; $i <= $pages; $i++ ) {
|
192 |
+
if ( $current === $i ) {
|
193 |
+
$html .= '<span class="btn btn-default">' . $i . '</span>';
|
194 |
+
} else {
|
195 |
+
$html .= '<a class="btn btn-primary" href="' . admin_url() . 'admin.php?' . $query_string . '&offset=' . $i . '">' . $i . '</a>';
|
196 |
+
}
|
197 |
+
}
|
198 |
+
}
|
199 |
+
|
200 |
+
$html .= '</div>';
|
201 |
+
|
202 |
+
return $html;
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Save all meta data.
|
207 |
+
*
|
208 |
+
* @param array $data The column key to name map.
|
209 |
+
*/
|
210 |
+
public function save_all( $data ) {
|
211 |
+
$post = ( ! empty( $_POST ) ) ? wc_clean( wp_unslash( $_POST ) ) : array(); // phpcs:ignore
|
212 |
+
foreach ( $data['product_id'] as $item ) {
|
213 |
+
WSM_Save::save_one_item( $post, $item );
|
214 |
+
}
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Save all meta data
|
219 |
+
*
|
220 |
+
* @param array $data The column display data.
|
221 |
+
*/
|
222 |
+
public function save_filter_display( $data ) {
|
223 |
+
$option = array();
|
224 |
+
if ( ! empty( $data['thumbnail'] ) ) {
|
225 |
+
$option['thumbnail'] = 'display';
|
226 |
+
} else {
|
227 |
+
$option['thumbnail'] = 'no'; }
|
228 |
+
if ( ! empty( $data['price'] ) ) {
|
229 |
+
$option['price'] = 'display';
|
230 |
+
} else {
|
231 |
+
$option['price'] = 'no'; }
|
232 |
+
if ( ! empty( $data['sales_price'] ) ) {
|
233 |
+
$option['sales_price'] = 'display';
|
234 |
+
} else {
|
235 |
+
$option['sales_price'] = 'no'; }
|
236 |
+
if ( ! empty( $data['weight'] ) ) {
|
237 |
+
$option['weight'] = 'display';
|
238 |
+
} else {
|
239 |
+
$option['weight'] = 'no'; }
|
240 |
+
if ( ! empty( $data['manage_stock'] ) ) {
|
241 |
+
$option['manage_stock'] = 'display';
|
242 |
+
} else {
|
243 |
+
$option['manage_stock'] = 'no'; }
|
244 |
+
if ( ! empty( $data['stock_status'] ) ) {
|
245 |
+
$option['stock_status'] = 'display';
|
246 |
+
} else {
|
247 |
+
$option['stock_status'] = 'no'; }
|
248 |
+
if ( ! empty( $data['backorders'] ) ) {
|
249 |
+
$option['backorders'] = 'display';
|
250 |
+
} else {
|
251 |
+
$option['backorders'] = 'no'; }
|
252 |
+
if ( ! empty( $data['stock'] ) ) {
|
253 |
+
$option['stock'] = 'display';
|
254 |
+
} else {
|
255 |
+
$option['stock'] = 'no'; }
|
256 |
+
if ( ! empty( $data['tax_status'] ) ) {
|
257 |
+
$option['tax_status'] = 'display';
|
258 |
+
} else {
|
259 |
+
$option['tax_status'] = 'no'; }
|
260 |
+
if ( ! empty( $data['tax_class'] ) ) {
|
261 |
+
$option['tax_class'] = 'display';
|
262 |
+
} else {
|
263 |
+
$option['tax_class'] = 'no'; }
|
264 |
+
if ( ! empty( $data['shipping_class'] ) ) {
|
265 |
+
$option['shipping_class'] = 'display';
|
266 |
+
} else {
|
267 |
+
$option['shipping_class'] = 'no'; }
|
268 |
+
|
269 |
+
if ( ! empty( $option ) ) {
|
270 |
+
update_option( 'wsm_display_option', $option, 'no' );
|
271 |
+
}
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Get products by sku.
|
276 |
+
*
|
277 |
+
* @param string $sku The product SKU to search.
|
278 |
+
*/
|
279 |
+
private function get_product_by_sku( $sku ) {
|
280 |
+
$args = array();
|
281 |
+
$args['post_type'] = array( 'product', 'product_variation' );
|
282 |
+
$args['meta_query'] = array( // phpcs:ignore
|
283 |
+
array(
|
284 |
+
'key' => '_sku',
|
285 |
+
'value' => $sku,
|
286 |
+
'compare' => 'LIKE',
|
287 |
+
),
|
288 |
+
);
|
289 |
+
$args['posts_per_page'] = $this->limit;
|
290 |
+
|
291 |
+
$the_query = new WP_Query( $args );
|
292 |
+
|
293 |
+
return $the_query;
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
* Get products by title.
|
298 |
+
*
|
299 |
+
* @param string $title The product title to search.
|
300 |
+
*/
|
301 |
+
private function get_product_by_product_title( $title ) {
|
302 |
+
|
303 |
+
add_filter( 'posts_search', 'wsm_search_by_title_only', 500, 2 );
|
304 |
+
|
305 |
+
$args = array();
|
306 |
+
$args['post_type'] = 'product';
|
307 |
+
$args['s'] = $title;
|
308 |
+
$args['post_status'] = 'publish';
|
309 |
+
$args['orderby'] = 'title';
|
310 |
+
$args['order'] = 'ASC';
|
311 |
+
$args['posts_per_page'] = $this->limit;
|
312 |
+
|
313 |
+
$passed_offset = ( ! empty( $_GET['offset'] ) ) ? wc_clean( wp_unslash( $_GET['offset'] ) ) : 0; // phpcs:ignore
|
314 |
+
|
315 |
+
$args['offset'] = ( ! empty( $passed_offset ) ) ? ( ( intval( $passed_offset ) - 1 ) * $this->limit ) : $passed_offset;
|
316 |
+
|
317 |
+
$the_query = new WP_Query( $args );
|
318 |
+
|
319 |
+
remove_filter( 'posts_search', 'wsm_search_by_title_only' );
|
320 |
+
|
321 |
+
return $the_query;
|
322 |
+
|
323 |
+
}
|
324 |
+
|
325 |
+
}//end class
|
admin/includes/config.php
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$config = array(
|
4 |
-
'sku' => array(
|
5 |
-
'type' => 'optional',
|
6 |
-
'name' => __( 'SKU', 'woocommerce-stock-manager' ),
|
7 |
-
'calback' => 'sku_box'
|
8 |
-
),
|
9 |
-
'product_id' => array(
|
10 |
-
'type' => 'optional',
|
11 |
-
'name' => __( 'ID', 'woocommerce-stock-manager' ),
|
12 |
-
'calback' => 'id_box'
|
13 |
-
),
|
14 |
-
'sku' => array(
|
15 |
-
'type' => 'optional',
|
16 |
-
'name' => __( 'SKU', 'woocommerce-stock-manager' ),
|
17 |
-
'calback' => 'sku_box'
|
18 |
-
),
|
19 |
-
'sku' => array(
|
20 |
-
'type' => 'optional',
|
21 |
-
'name' => __( 'SKU', 'woocommerce-stock-manager' ),
|
22 |
-
'calback' => 'sku_box'
|
23 |
-
),
|
24 |
-
'sku' => array(
|
25 |
-
'type' => 'optional',
|
26 |
-
'name' => __( 'SKU', 'woocommerce-stock-manager' ),
|
27 |
-
'calback' => 'sku_box'
|
28 |
-
),
|
29 |
-
'sku' => array(
|
30 |
-
'type' => 'optional',
|
31 |
-
'name' => __( 'SKU', 'woocommerce-stock-manager' ),
|
32 |
-
'calback' => 'sku_box'
|
33 |
-
),
|
34 |
-
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/includes/index.php
CHANGED
@@ -1,2 +1,10 @@
|
|
1 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
2 |
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silence is golden
|
4 |
+
*
|
5 |
+
* @package woocommerce-stock-manager/admin/includes/
|
6 |
+
*/
|
7 |
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
admin/includes/wcm-class-stock.php
DELETED
@@ -1,342 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Stock class
|
4 |
-
*
|
5 |
-
* @package woocommerce-stock-manager/admin/includes/
|
6 |
-
* @version 2.7.0
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
-
exit;
|
11 |
-
}
|
12 |
-
|
13 |
-
class WCM_Stock {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Instance of this class.
|
17 |
-
*
|
18 |
-
* @since 1.0.0
|
19 |
-
*
|
20 |
-
* @var object
|
21 |
-
*/
|
22 |
-
protected static $instance = null;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Constructor for the stock class.
|
26 |
-
*
|
27 |
-
* @since 1.0.0
|
28 |
-
*/
|
29 |
-
public $limit = 100;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Constructor for the stock class.
|
33 |
-
*
|
34 |
-
* @since 1.0.0
|
35 |
-
*/
|
36 |
-
private function __construct() {
|
37 |
-
|
38 |
-
$limit = get_option( 'woocommerce_stock_limit' );
|
39 |
-
if( !empty( $limit ) ) {
|
40 |
-
$this->limit = $limit;
|
41 |
-
}
|
42 |
-
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Return an instance of this class.
|
47 |
-
*
|
48 |
-
* @since 1.0.0
|
49 |
-
*
|
50 |
-
* @return object A single instance of this class.
|
51 |
-
*/
|
52 |
-
public static function get_instance() {
|
53 |
-
|
54 |
-
// If the single instance hasn't been set, set it now.
|
55 |
-
if ( null == self::$instance ) {
|
56 |
-
self::$instance = new self;
|
57 |
-
}
|
58 |
-
|
59 |
-
return self::$instance;
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Return products
|
64 |
-
*
|
65 |
-
*
|
66 |
-
* @since 1.0.0
|
67 |
-
*/
|
68 |
-
public function get_products($data = array()){
|
69 |
-
|
70 |
-
if( isset( $_GET['sku'] ) ) {
|
71 |
-
return $this->get_product_by_sku( $_GET['sku'] );
|
72 |
-
}
|
73 |
-
|
74 |
-
if( isset( $_GET['product-title'] ) ) {
|
75 |
-
return $this->get_product_by_product_title( $_GET['product-title'] );
|
76 |
-
}
|
77 |
-
|
78 |
-
$args = array();
|
79 |
-
$args['post_type'] = 'product';
|
80 |
-
|
81 |
-
// Initialize tax_query array
|
82 |
-
if( !empty( $_GET['product-type'] ) || !empty( $_GET['product-category'] ) ) {
|
83 |
-
$args['tax_query'] = array();
|
84 |
-
|
85 |
-
if(isset($_GET['product-type'])) {
|
86 |
-
if($_GET['product-type'] == 'variable') {
|
87 |
-
$args['tax_query'][] = array(
|
88 |
-
'taxonomy' => 'product_type',
|
89 |
-
'terms' => 'variable',
|
90 |
-
'field' => 'slug'
|
91 |
-
);
|
92 |
-
} else {
|
93 |
-
$args['tax_query'] = array(
|
94 |
-
'taxonomy' => 'product_type',
|
95 |
-
'terms' => 'simple',
|
96 |
-
'field' => 'slug'
|
97 |
-
);
|
98 |
-
}
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Product category filter
|
103 |
-
*/
|
104 |
-
if( isset( $_GET['product-category'] ) ) {
|
105 |
-
if( $_GET['product-category'] != 'all' ) {
|
106 |
-
$category = $_GET['product-category'];
|
107 |
-
$args['tax_query'][] = array(
|
108 |
-
'taxonomy' => 'product_cat',
|
109 |
-
'terms' => $category,
|
110 |
-
'field' => 'term_id'
|
111 |
-
);
|
112 |
-
}
|
113 |
-
}
|
114 |
-
|
115 |
-
}
|
116 |
-
|
117 |
-
// Initialize meta_query array
|
118 |
-
if( !empty( $_GET['stock-status'] ) || !empty( $_GET['manage-stock'] ) ){
|
119 |
-
$args['meta_query'] = array();
|
120 |
-
|
121 |
-
|
122 |
-
if(!empty($_GET['stock-status'])){
|
123 |
-
$status = $_GET['stock-status'];
|
124 |
-
|
125 |
-
$args['meta_query'][] = array(
|
126 |
-
'key' => '_stock_status',
|
127 |
-
'value' => $status,
|
128 |
-
'compare' => '=',
|
129 |
-
);
|
130 |
-
|
131 |
-
}
|
132 |
-
|
133 |
-
if(!empty($_GET['manage-stock'])){
|
134 |
-
$manage = $_GET['manage-stock'];
|
135 |
-
|
136 |
-
$args['meta_query'][] = array(
|
137 |
-
'key' => '_manage_stock',
|
138 |
-
'value' => $manage,
|
139 |
-
'compare' => '=',
|
140 |
-
);
|
141 |
-
|
142 |
-
}
|
143 |
-
}
|
144 |
-
|
145 |
-
if(isset($_GET['order-by'])){
|
146 |
-
$order_by = $_GET['order-by'];
|
147 |
-
|
148 |
-
if( $order_by == 'name-asc' ){
|
149 |
-
|
150 |
-
$args['orderby'] = 'title';
|
151 |
-
$args['order'] = 'ASC';
|
152 |
-
|
153 |
-
}
|
154 |
-
elseif( $order_by == 'name-desc' ){
|
155 |
-
|
156 |
-
$args['orderby'] = 'title';
|
157 |
-
$args['order'] = 'DESC';
|
158 |
-
|
159 |
-
}
|
160 |
-
elseif( $order_by == 'sku-asc' ){
|
161 |
-
|
162 |
-
$args['meta_key'] = '_sku';
|
163 |
-
$args['orderby'] = 'meta_value';
|
164 |
-
$args['order'] = 'ASC';
|
165 |
-
|
166 |
-
}
|
167 |
-
elseif( $order_by == 'sku-desc' ){
|
168 |
-
|
169 |
-
$args['meta_key'] = '_sku';
|
170 |
-
$args['orderby'] = 'meta_value';
|
171 |
-
$args['order'] = 'DESC';
|
172 |
-
|
173 |
-
}
|
174 |
-
|
175 |
-
|
176 |
-
}
|
177 |
-
|
178 |
-
$args['posts_per_page'] = $this->limit;
|
179 |
-
|
180 |
-
|
181 |
-
if(!empty($_GET['offset'])){
|
182 |
-
$offset = $_GET['offset'] - 1;
|
183 |
-
$offset = $offset * $this->limit;
|
184 |
-
$args['offset'] = $offset;
|
185 |
-
|
186 |
-
}
|
187 |
-
|
188 |
-
$the_query = new WP_Query( $args );
|
189 |
-
|
190 |
-
return $the_query;
|
191 |
-
}
|
192 |
-
|
193 |
-
/**
|
194 |
-
* Return pagination
|
195 |
-
*
|
196 |
-
*/
|
197 |
-
public function pagination( $query ) {
|
198 |
-
|
199 |
-
if( isset( $_GET['sku'] ) ) {
|
200 |
-
return false;
|
201 |
-
}
|
202 |
-
|
203 |
-
$all = $query->found_posts;
|
204 |
-
|
205 |
-
$pages = ceil($all / $this->limit);
|
206 |
-
if( !empty( $_GET['offset'] ) ) {
|
207 |
-
$current = $_GET['offset'];
|
208 |
-
} else {
|
209 |
-
$current = 1;
|
210 |
-
}
|
211 |
-
|
212 |
-
$html = '';
|
213 |
-
$html .= '<div class="stock-manager-pagination">';
|
214 |
-
$query_string = $_SERVER['QUERY_STRING'];
|
215 |
-
if($pages != 1) {
|
216 |
-
for ($i=1; $i <= $pages; $i++) {
|
217 |
-
if($current == $i) {
|
218 |
-
$html .= '<span class="btn btn-default">'.$i.'</span>';
|
219 |
-
} else {
|
220 |
-
$html .= '<a class="btn btn-primary" href="'.admin_url().'admin.php?'.$query_string.'&offset='.$i.'">'.$i.'</a>';
|
221 |
-
}
|
222 |
-
}
|
223 |
-
}
|
224 |
-
|
225 |
-
$html .= '</div>';
|
226 |
-
|
227 |
-
return $html;
|
228 |
-
}
|
229 |
-
|
230 |
-
/**
|
231 |
-
* Save all meta data
|
232 |
-
*
|
233 |
-
*/
|
234 |
-
public function save_all( $data ){
|
235 |
-
foreach( $data['product_id'] as $key => $item ) {
|
236 |
-
$product_id = sanitize_text_field( $item );
|
237 |
-
WCM_Save::save_one_item( $_POST, $product_id );
|
238 |
-
}
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
* Save all meta data
|
243 |
-
*
|
244 |
-
*/
|
245 |
-
public function save_filter_display($data){
|
246 |
-
$option = array();
|
247 |
-
if( !empty( $data['thumbnail'] ) ){ $option['thumbnail'] = 'display'; }else{ $option['thumbnail'] = 'no'; }
|
248 |
-
if( !empty( $data['price'] ) ){ $option['price'] = 'display'; }else{ $option['price'] = 'no'; }
|
249 |
-
if( !empty( $data['sales_price'] ) ){ $option['sales_price'] = 'display'; }else{ $option['sales_price'] = 'no'; }
|
250 |
-
if( !empty( $data['weight'] ) ){ $option['weight'] = 'display'; }else{ $option['weight'] = 'no'; }
|
251 |
-
if( !empty( $data['manage_stock'] ) ){ $option['manage_stock'] = 'display'; }else{ $option['manage_stock'] = 'no'; }
|
252 |
-
if( !empty( $data['stock_status'] ) ){ $option['stock_status'] = 'display'; }else{ $option['stock_status'] = 'no'; }
|
253 |
-
if( !empty( $data['backorders'] ) ){ $option['backorders'] = 'display'; }else{ $option['backorders'] = 'no'; }
|
254 |
-
if( !empty( $data['stock'] ) ){ $option['stock'] = 'display'; }else{ $option['stock'] = 'no'; }
|
255 |
-
if( !empty( $data['tax_status'] ) ){ $option['tax_status'] = 'display'; }else{ $option['tax_status'] = 'no'; }
|
256 |
-
if( !empty( $data['tax_class'] ) ){ $option['tax_class'] = 'display'; }else{ $option['tax_class'] = 'no'; }
|
257 |
-
if( !empty( $data['shipping_class'] ) ){ $option['shipping_class'] = 'display'; }else{ $option['shipping_class'] = 'no'; }
|
258 |
-
|
259 |
-
if( !empty( $option ) ){
|
260 |
-
update_option( 'wsm_display_option', $option, 'no' );
|
261 |
-
}
|
262 |
-
}
|
263 |
-
|
264 |
-
/**
|
265 |
-
* Get prduct categories
|
266 |
-
*
|
267 |
-
*/
|
268 |
-
public function products_categories($selected = null){
|
269 |
-
$out = '';
|
270 |
-
|
271 |
-
$terms = get_terms(
|
272 |
-
'product_cat',
|
273 |
-
array(
|
274 |
-
'hide_empty' => 0,
|
275 |
-
'orderby' => 'ASC'
|
276 |
-
)
|
277 |
-
);
|
278 |
-
if(count($terms) > 0)
|
279 |
-
{
|
280 |
-
foreach ($terms as $term)
|
281 |
-
{
|
282 |
-
if(!empty($selected) && $selected == $term->term_id){ $sel = 'selected="selected"'; }else{ $sel = ''; }
|
283 |
-
$out .= '<option value="'.$term->term_id.'" '.$sel.'>'.$term->name.'</option>';
|
284 |
-
}
|
285 |
-
return $out;
|
286 |
-
}
|
287 |
-
return;
|
288 |
-
}
|
289 |
-
|
290 |
-
/**
|
291 |
-
* Get products by sku
|
292 |
-
*
|
293 |
-
*/
|
294 |
-
private function get_product_by_sku( $sku ){
|
295 |
-
$args = array();
|
296 |
-
$args['post_type'] = array( 'product', 'product_variation' );
|
297 |
-
$args['meta_query'] = array(
|
298 |
-
array(
|
299 |
-
'key' => '_sku',
|
300 |
-
'value' => $sku,
|
301 |
-
'compare' => 'LIKE'
|
302 |
-
)
|
303 |
-
);
|
304 |
-
$args['posts_per_page'] = $this->limit;
|
305 |
-
|
306 |
-
$the_query = new WP_Query( $args );
|
307 |
-
|
308 |
-
return $the_query;
|
309 |
-
}
|
310 |
-
|
311 |
-
/**
|
312 |
-
* Get products by sku
|
313 |
-
*
|
314 |
-
*/
|
315 |
-
private function get_product_by_product_title( $title ){
|
316 |
-
|
317 |
-
add_filter( 'posts_search', 'wsm_search_by_title_only', 500, 2 );
|
318 |
-
|
319 |
-
$args = array();
|
320 |
-
$args['post_type'] = 'product';
|
321 |
-
$args['s'] = $title;
|
322 |
-
$args['post_status'] = 'publish';
|
323 |
-
$args['orderby'] = 'title';
|
324 |
-
$args['order'] = 'ASC';
|
325 |
-
$args['posts_per_page'] = $this->limit;
|
326 |
-
|
327 |
-
if( !empty( $_GET['offset'] ) ){
|
328 |
-
$offset = $_GET['offset'] - 1;
|
329 |
-
$offset = $offset * $this->limit;
|
330 |
-
$args['offset'] = $offset;
|
331 |
-
|
332 |
-
}
|
333 |
-
|
334 |
-
$the_query = new WP_Query( $args );
|
335 |
-
|
336 |
-
remove_filter( 'posts_search', 'wsm_search_by_title_only' );
|
337 |
-
|
338 |
-
return $the_query;
|
339 |
-
|
340 |
-
}
|
341 |
-
|
342 |
-
}//End class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/includes/wcm-class-table.php
DELETED
@@ -1,800 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Table
|
4 |
-
*
|
5 |
-
* @package woocommerce-stock-manager/admin/includes/
|
6 |
-
* @version 2.7.0
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
-
exit;
|
11 |
-
}
|
12 |
-
|
13 |
-
class WCM_Table {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Instance of this class.
|
17 |
-
*
|
18 |
-
* @since 1.0.5
|
19 |
-
*
|
20 |
-
* @var object
|
21 |
-
*/
|
22 |
-
protected static $instance = null;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Constructor for the stock class.
|
26 |
-
*
|
27 |
-
* @since 1.0.5
|
28 |
-
*/
|
29 |
-
private function __construct() {
|
30 |
-
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Return an instance of this class.
|
35 |
-
*
|
36 |
-
* @since 1.0.5
|
37 |
-
*
|
38 |
-
* @return object A single instance of this class.
|
39 |
-
*/
|
40 |
-
public static function get_instance() {
|
41 |
-
|
42 |
-
// If the single instance hasn't been set, set it now.
|
43 |
-
if ( null == self::$instance ) {
|
44 |
-
self::$instance = new self;
|
45 |
-
}
|
46 |
-
|
47 |
-
return self::$instance;
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Row filter
|
52 |
-
*
|
53 |
-
* @since 1.0.5
|
54 |
-
*/
|
55 |
-
public static function row_filter($product_meta, $id){
|
56 |
-
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Display option
|
61 |
-
*
|
62 |
-
* @since 1.1.2
|
63 |
-
*/
|
64 |
-
public static function display_option(){
|
65 |
-
$display_option = get_option( 'wsm_display_option' );
|
66 |
-
|
67 |
-
if( empty( $display_option ) ){
|
68 |
-
$display_option = array(
|
69 |
-
'price' => 'display',
|
70 |
-
'sales_price' => 'no',
|
71 |
-
'weight' => 'display',
|
72 |
-
'manage_stock' => 'display',
|
73 |
-
'stock_status' => 'display',
|
74 |
-
'backorders' => 'display',
|
75 |
-
'stock' => 'display',
|
76 |
-
);
|
77 |
-
}
|
78 |
-
return $display_option;
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Table header
|
83 |
-
*
|
84 |
-
* @since 1.1.2
|
85 |
-
*/
|
86 |
-
public static function table_header_line(){
|
87 |
-
|
88 |
-
$display_option = self::display_option();
|
89 |
-
|
90 |
-
echo '<th></th>';
|
91 |
-
|
92 |
-
if(!empty( $display_option['thumbnail'] ) && $display_option['thumbnail'] == 'display' ){
|
93 |
-
self::table_head_thumbnail();
|
94 |
-
}
|
95 |
-
self::table_head_sku();
|
96 |
-
self::table_head_id();
|
97 |
-
self::table_head_name();
|
98 |
-
self::table_head_product_type();
|
99 |
-
self::table_head_parent_id();
|
100 |
-
|
101 |
-
if(!empty( $display_option['tax_status'] ) && $display_option['tax_status'] == 'display' ){
|
102 |
-
echo '<th>'.__('Tax status','woocommerce-stock-manager').'</th>';
|
103 |
-
}
|
104 |
-
if(!empty( $display_option['tax_class'] ) && $display_option['tax_class'] == 'display' ){
|
105 |
-
echo '<th>'.__('Tax class','woocommerce-stock-manager').'</th>';
|
106 |
-
}
|
107 |
-
if(!empty( $display_option['shipping_class'] ) && $display_option['shipping_class'] == 'display' ){
|
108 |
-
echo '<th>'.__('Shipping class','woocommerce-stock-manager').'</th>';
|
109 |
-
}
|
110 |
-
if(!empty( $display_option['price'] ) && $display_option['price'] == 'display' ){
|
111 |
-
self::table_head_price();
|
112 |
-
}
|
113 |
-
if(!empty( $display_option['sales_price'] ) && $display_option['sales_price'] == 'display' ){
|
114 |
-
self::table_head_sales_price();
|
115 |
-
}
|
116 |
-
if(!empty( $display_option['weight'] ) && $display_option['weight'] == 'display' ){
|
117 |
-
self::table_head_weight();
|
118 |
-
}
|
119 |
-
if(!empty( $display_option['manage_stock'] ) && $display_option['manage_stock'] == 'display' ){
|
120 |
-
self::table_head_manage_stock();
|
121 |
-
}
|
122 |
-
if(!empty( $display_option['stock_status'] ) && $display_option['stock_status'] == 'display' ){
|
123 |
-
self::table_head_stock_status();
|
124 |
-
}
|
125 |
-
if(!empty( $display_option['backorders'] ) && $display_option['backorders'] == 'display' ){
|
126 |
-
self::table_head_backorders();
|
127 |
-
}
|
128 |
-
|
129 |
-
if(!empty( $display_option['stock'] ) && $display_option['stock'] == 'display' ){
|
130 |
-
self::table_head_stock();
|
131 |
-
}
|
132 |
-
do_action( 'stock_manager_table_th' );
|
133 |
-
self::table_head_save();
|
134 |
-
|
135 |
-
}
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Table simple line
|
139 |
-
*
|
140 |
-
* @since 1.1.2
|
141 |
-
*/
|
142 |
-
public static function table_simple_line( $product_meta, $item, $product_type, $product ){
|
143 |
-
|
144 |
-
$display_option = self::display_option();
|
145 |
-
|
146 |
-
if(!empty( $display_option['tax_status'] ) && $display_option['tax_status'] == 'display' ){
|
147 |
-
self::tax_status_box( $product_meta, $item, $product_type );
|
148 |
-
}
|
149 |
-
if(!empty( $display_option['tax_class'] ) && $display_option['tax_class'] == 'display' ){
|
150 |
-
self::tax_class_box( $product_meta, $item, $product_type );
|
151 |
-
}
|
152 |
-
if(!empty( $display_option['shipping_class'] ) && $display_option['shipping_class'] == 'display' ){
|
153 |
-
self::shipping_class_box( $product_meta, $item, $product_type );
|
154 |
-
}
|
155 |
-
if(!empty( $display_option['price'] ) && $display_option['price'] == 'display' ){
|
156 |
-
self::price_box( $product_meta, $item, $product_type );
|
157 |
-
}
|
158 |
-
if(!empty( $display_option['sales_price'] ) && $display_option['sales_price'] == 'display' ){
|
159 |
-
self::sales_price_box( $product_meta, $item, $product_type );
|
160 |
-
}
|
161 |
-
if(!empty( $display_option['weight'] ) && $display_option['weight'] == 'display' ){
|
162 |
-
self::weight_box($product_meta, $item);
|
163 |
-
}
|
164 |
-
if(!empty( $display_option['manage_stock'] ) && $display_option['manage_stock'] == 'display' ){
|
165 |
-
self::manage_stock_box($product_meta, $item);
|
166 |
-
}
|
167 |
-
if(!empty( $display_option['stock_status'] ) && $display_option['stock_status'] == 'display' ){
|
168 |
-
self::stock_status_box($product_meta, $item);
|
169 |
-
}
|
170 |
-
if(!empty( $display_option['backorders'] ) && $display_option['backorders'] == 'display' ){
|
171 |
-
self::backorders_box($product_meta, $item);
|
172 |
-
}
|
173 |
-
if(!empty( $display_option['stock'] ) && $display_option['stock'] == 'display' ){
|
174 |
-
self::qty_box( $product_meta, $item, $product );
|
175 |
-
}
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
/**
|
180 |
-
* Table variation line
|
181 |
-
*
|
182 |
-
* @since 1.1.2
|
183 |
-
*/
|
184 |
-
public static function table_variation_line( $product_meta, $item, $product ){
|
185 |
-
|
186 |
-
$display_option = self::display_option();
|
187 |
-
|
188 |
-
$product_type = 'variation';
|
189 |
-
|
190 |
-
if(!empty( $display_option['tax_status'] ) && $display_option['tax_status'] == 'display' ){
|
191 |
-
self::tax_status_box( $product_meta, $item, $product_type );
|
192 |
-
}
|
193 |
-
if(!empty( $display_option['tax_class'] ) && $display_option['tax_class'] == 'display' ){
|
194 |
-
self::tax_class_box( $product_meta, $item, $product_type );
|
195 |
-
}
|
196 |
-
if(!empty( $display_option['shipping_class'] ) && $display_option['shipping_class'] == 'display' ){
|
197 |
-
self::shipping_class_box( $product_meta, $item, $product_type );
|
198 |
-
}
|
199 |
-
if(!empty( $display_option['price'] ) && $display_option['price'] == 'display' ){
|
200 |
-
self::price_box($product_meta, $item);
|
201 |
-
}
|
202 |
-
if(!empty( $display_option['sales_price'] ) && $display_option['sales_price'] == 'display' ){
|
203 |
-
self::sales_price_box($product_meta, $item);
|
204 |
-
}
|
205 |
-
if(!empty( $display_option['weight'] ) && $display_option['weight'] == 'display' ){
|
206 |
-
self::weight_box($product_meta, $item);
|
207 |
-
}
|
208 |
-
if(!empty( $display_option['manage_stock'] ) && $display_option['manage_stock'] == 'display' ){
|
209 |
-
self::manage_stock_box($product_meta, $item);
|
210 |
-
}
|
211 |
-
if(!empty( $display_option['stock_status'] ) && $display_option['stock_status'] == 'display' ){
|
212 |
-
self::stock_status_box($product_meta, $item);
|
213 |
-
}
|
214 |
-
if(!empty( $display_option['backorders'] ) && $display_option['backorders'] == 'display' ){
|
215 |
-
self::backorders_box($product_meta, $item);
|
216 |
-
}
|
217 |
-
if(!empty( $display_option['stock'] ) && $display_option['stock'] == 'display' ){
|
218 |
-
self::qty_box($product_meta, $item, $product);
|
219 |
-
}
|
220 |
-
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* Table head Thumbnail
|
225 |
-
*
|
226 |
-
* @since 1.1.9
|
227 |
-
*/
|
228 |
-
public static function table_head_thumbnail(){
|
229 |
-
?>
|
230 |
-
<th><?php _e('Thumbnail','woocommerce-stock-manager'); ?></th>
|
231 |
-
<?php
|
232 |
-
}
|
233 |
-
|
234 |
-
/**
|
235 |
-
* Table head Sku
|
236 |
-
*
|
237 |
-
* @since 1.1.2
|
238 |
-
*/
|
239 |
-
public static function table_head_sku(){
|
240 |
-
?>
|
241 |
-
<th style="width:100px;"><?php _e('SKU','woocommerce-stock-manager'); ?></th>
|
242 |
-
<?php
|
243 |
-
}
|
244 |
-
|
245 |
-
/**
|
246 |
-
* Table head ID
|
247 |
-
*
|
248 |
-
* @since 1.1.2
|
249 |
-
*/
|
250 |
-
public static function table_head_id(){
|
251 |
-
?>
|
252 |
-
<th><?php _e('ID','woocommerce-stock-manager'); ?></th>
|
253 |
-
<?php
|
254 |
-
}
|
255 |
-
|
256 |
-
/**
|
257 |
-
* Table head Name
|
258 |
-
*
|
259 |
-
* @since 1.1.2
|
260 |
-
*/
|
261 |
-
public static function table_head_name(){
|
262 |
-
?>
|
263 |
-
<th><?php _e('Name','woocommerce-stock-manager'); ?></th>
|
264 |
-
<?php
|
265 |
-
}
|
266 |
-
|
267 |
-
/**
|
268 |
-
* Table head Product type
|
269 |
-
*
|
270 |
-
* @since 1.1.2
|
271 |
-
*/
|
272 |
-
public static function table_head_product_type(){
|
273 |
-
?>
|
274 |
-
<th><?php _e('Product type','woocommerce-stock-manager'); ?></th>
|
275 |
-
<?php
|
276 |
-
}
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Table head Parent ID
|
280 |
-
*
|
281 |
-
* @since 1.1.2
|
282 |
-
*/
|
283 |
-
public static function table_head_parent_id(){
|
284 |
-
?>
|
285 |
-
<th><?php _e('Parent ID','woocommerce-stock-manager'); ?></th>
|
286 |
-
<?php
|
287 |
-
}
|
288 |
-
|
289 |
-
/**
|
290 |
-
* Table head Price
|
291 |
-
*
|
292 |
-
* @since 1.1.2
|
293 |
-
*/
|
294 |
-
public static function table_head_price(){
|
295 |
-
?>
|
296 |
-
<th><?php _e('Price','woocommerce-stock-manager'); ?></th>
|
297 |
-
<?php
|
298 |
-
}
|
299 |
-
|
300 |
-
/**
|
301 |
-
* Table head Price
|
302 |
-
*
|
303 |
-
* @since 1.1.2
|
304 |
-
*/
|
305 |
-
public static function table_head_sales_price(){
|
306 |
-
?>
|
307 |
-
<th><?php _e('Sale price','woocommerce-stock-manager'); ?></th>
|
308 |
-
<?php
|
309 |
-
}
|
310 |
-
|
311 |
-
/**
|
312 |
-
* Table head Weight
|
313 |
-
*
|
314 |
-
* @since 1.1.2
|
315 |
-
*/
|
316 |
-
public static function table_head_weight(){
|
317 |
-
?>
|
318 |
-
<th><?php _e('Weight','woocommerce-stock-manager'); ?></th>
|
319 |
-
<?php
|
320 |
-
}
|
321 |
-
|
322 |
-
/**
|
323 |
-
* Table head Manage stock
|
324 |
-
*
|
325 |
-
* @since 1.1.2
|
326 |
-
*/
|
327 |
-
public static function table_head_manage_stock(){
|
328 |
-
?>
|
329 |
-
<th><?php _e('Manage stock','woocommerce-stock-manager'); ?></th>
|
330 |
-
<?php
|
331 |
-
}
|
332 |
-
|
333 |
-
/**
|
334 |
-
* Table head Stock status
|
335 |
-
*
|
336 |
-
* @since 1.1.2
|
337 |
-
*/
|
338 |
-
public static function table_head_stock_status(){
|
339 |
-
?>
|
340 |
-
<th style="width:80px;"><?php _e('Stock status','woocommerce-stock-manager'); ?></th>
|
341 |
-
<?php
|
342 |
-
}
|
343 |
-
|
344 |
-
/**
|
345 |
-
* Table head Backorders
|
346 |
-
*
|
347 |
-
* @since 1.1.2
|
348 |
-
*/
|
349 |
-
public static function table_head_backorders(){
|
350 |
-
?>
|
351 |
-
<th><?php _e('Backorders','woocommerce-stock-manager'); ?></th>
|
352 |
-
<?php
|
353 |
-
}
|
354 |
-
|
355 |
-
/**
|
356 |
-
* Table head Stock
|
357 |
-
*
|
358 |
-
* @since 1.1.2
|
359 |
-
*/
|
360 |
-
public static function table_head_stock(){
|
361 |
-
?>
|
362 |
-
<th style="width:50px;"><?php _e('Stock','woocommerce-stock-manager'); ?></th>
|
363 |
-
<?php
|
364 |
-
}
|
365 |
-
|
366 |
-
/**
|
367 |
-
* Table head Save
|
368 |
-
*
|
369 |
-
* @since 1.1.2
|
370 |
-
*/
|
371 |
-
public static function table_head_save(){
|
372 |
-
?>
|
373 |
-
<th style="width:100px;"><?php _e('Save','woocommerce-stock-manager'); ?></th>
|
374 |
-
<?php
|
375 |
-
}
|
376 |
-
|
377 |
-
/**
|
378 |
-
* Hidden box
|
379 |
-
*
|
380 |
-
* @since 1.1.2
|
381 |
-
*/
|
382 |
-
public static function hidden_box( $item ){
|
383 |
-
?>
|
384 |
-
<input type="hidden" name="product_id[<?php echo $item; ?>]" value="<?php echo $item; ?>" />
|
385 |
-
<?php
|
386 |
-
}
|
387 |
-
|
388 |
-
/**
|
389 |
-
* Thumbnail box
|
390 |
-
*
|
391 |
-
* @since 1.1.9
|
392 |
-
*/
|
393 |
-
public static function thumbnail_box( $item ) {
|
394 |
-
$display_option = self::display_option();
|
395 |
-
if(!empty( $display_option['thumbnail'] ) && $display_option['thumbnail'] == 'display' ){
|
396 |
-
$_product = wc_get_product( $item );
|
397 |
-
$thumbnail = $_product->get_image( 'shop_thumbnail' );
|
398 |
-
?>
|
399 |
-
<td class="item_thumbnail_box">
|
400 |
-
<?php echo $thumbnail; ?>
|
401 |
-
</td>
|
402 |
-
<?php
|
403 |
-
}
|
404 |
-
}
|
405 |
-
|
406 |
-
/**
|
407 |
-
* SKU box
|
408 |
-
*
|
409 |
-
* @since 1.1.2
|
410 |
-
*/
|
411 |
-
public static function sku_box($product_meta, $item){
|
412 |
-
?>
|
413 |
-
<td class="item_sku_box">
|
414 |
-
<span class="item-sku-text-<?php echo $item; ?>"><?php if(!empty($product_meta['_sku'][0])){ echo $product_meta['_sku'][0]; } ?></span>
|
415 |
-
<span class="dashicons dashicons-edit" data-item="<?php echo $item; ?>"></span>
|
416 |
-
<div class="item-sku-wrap item-sku-wrap-<?php echo $item; ?>">
|
417 |
-
<input type="text" name="sku[<?php echo $item; ?>]" style="width:100%;" class="item-sku sku_<?php echo $item; ?>" value="<?php if(!empty($product_meta['_sku'][0])){ echo $product_meta['_sku'][0]; } ?>" />
|
418 |
-
<span class="btn btn-info item-sku-button" data-item="<?php echo $item; ?>"><?php _e('Save', 'woocommerce-stock-manager'); ?></span>
|
419 |
-
<span class="btn btn-danger item-sku-button-close"><?php _e('Close', 'woocommerce-stock-manager'); ?></span>
|
420 |
-
</div>
|
421 |
-
</td>
|
422 |
-
<?php
|
423 |
-
}
|
424 |
-
|
425 |
-
/**
|
426 |
-
* ID box
|
427 |
-
*
|
428 |
-
* @since 1.1.2
|
429 |
-
*/
|
430 |
-
public static function id_box( $item ){
|
431 |
-
?>
|
432 |
-
<td class="td_center"><?php echo $item; ?></td>
|
433 |
-
<?php
|
434 |
-
}
|
435 |
-
|
436 |
-
/**
|
437 |
-
* Name box
|
438 |
-
*
|
439 |
-
* @since 1.1.2
|
440 |
-
*/
|
441 |
-
public static function name_box( $item ){
|
442 |
-
?>
|
443 |
-
<td class="table_name_box">
|
444 |
-
<a href="<?php echo admin_url().'post.php?post='.$item.'&action=edit'; ?>" target="_blank" class="item-post-link-<?php echo $item; ?>">
|
445 |
-
<?php echo get_the_title( $item ); ?>
|
446 |
-
</a>
|
447 |
-
<span class="dashicons dashicons-edit" data-item="<?php echo $item; ?>"></span>
|
448 |
-
<div class="item-post-title-wrap item-post-title-wrap-<?php echo $item; ?>">
|
449 |
-
<input type="text" name="item-post-title" class="item-post-title item-post-title-<?php echo $item; ?>" value="<?php echo get_the_title( $item ); ?>" />
|
450 |
-
<span class="btn btn-info item-post-title-button" data-item="<?php echo $item; ?>"><?php _e('Save', 'woocommerce-stock-manager'); ?></span>
|
451 |
-
<span class="btn btn-danger item-post-title-button-close"><?php _e('Close', 'woocommerce-stock-manager'); ?></span>
|
452 |
-
</div>
|
453 |
-
</td>
|
454 |
-
<?php
|
455 |
-
}
|
456 |
-
|
457 |
-
/**
|
458 |
-
* Show variables box
|
459 |
-
*
|
460 |
-
* @since 1.1.2
|
461 |
-
*/
|
462 |
-
public static function show_variables_box( $item, $product_type ){
|
463 |
-
?>
|
464 |
-
<td class="td_center">
|
465 |
-
<?php if($product_type == 'variable'){
|
466 |
-
echo '<span class="btn btn-info btn-sm show-variable" data-variable="'.$item.'">'.__('Show variables','woocommerce-stock-manager').'</span>';
|
467 |
-
}else{
|
468 |
-
echo $product_type;
|
469 |
-
} ?>
|
470 |
-
</td>
|
471 |
-
<?php
|
472 |
-
}
|
473 |
-
|
474 |
-
/**
|
475 |
-
* Tax status box
|
476 |
-
*
|
477 |
-
* @since 1.1.2
|
478 |
-
*/
|
479 |
-
public static function tax_status_box( $product_meta, $id, $product_type = null ){
|
480 |
-
|
481 |
-
$product = wc_get_product( $id );
|
482 |
-
|
483 |
-
if( $product_type == 'simple' || $product_type == 'variable' ){
|
484 |
-
$value = $product->get_tax_status( 'edit' );
|
485 |
-
$values = array(
|
486 |
-
'taxable' => __( 'Taxable', 'woocommerce-woocommerce' ),
|
487 |
-
'shipping' => __( 'Shipping only', 'woocommerce-woocommerce' ),
|
488 |
-
'none' => _x( 'None', 'Tax status', 'woocommerce-woocommerce' ),
|
489 |
-
);
|
490 |
-
?>
|
491 |
-
<td>
|
492 |
-
<select class="tax_status<?php echo $id; ?>" name="tax_status[<?php echo $id; ?>]">
|
493 |
-
<?php
|
494 |
-
foreach( $values as $key => $item ){
|
495 |
-
?>
|
496 |
-
<option value="<?php echo $key; ?>" <?php if( $value == $key ){ echo 'selected="selected"'; } ?>><?php echo $item; ?></option>
|
497 |
-
<?php
|
498 |
-
}
|
499 |
-
?>
|
500 |
-
</select>
|
501 |
-
</td>
|
502 |
-
<?php
|
503 |
-
}else{
|
504 |
-
?><td></td><?php
|
505 |
-
}
|
506 |
-
}
|
507 |
-
|
508 |
-
/**
|
509 |
-
* Tax calss box
|
510 |
-
*
|
511 |
-
* @since 1.1.2
|
512 |
-
*/
|
513 |
-
public static function tax_class_box( $product_meta, $id, $product_type = null ){
|
514 |
-
|
515 |
-
$product = wc_get_product( $id );
|
516 |
-
|
517 |
-
$value = $product->get_tax_class( 'edit' );
|
518 |
-
$values = wc_get_product_tax_class_options();
|
519 |
-
?>
|
520 |
-
<td>
|
521 |
-
<select class="tax_class<?php echo $id; ?>" name="tax_class[<?php echo $id; ?>]">
|
522 |
-
<?php
|
523 |
-
foreach( $values as $key => $item ){
|
524 |
-
?>
|
525 |
-
<option value="<?php echo $key; ?>" <?php if( $value == $key ){ echo 'selected="selected"'; } ?>><?php echo $item; ?></option>
|
526 |
-
<?php
|
527 |
-
}
|
528 |
-
?>
|
529 |
-
</select>
|
530 |
-
</td>
|
531 |
-
<?php
|
532 |
-
}
|
533 |
-
|
534 |
-
/**
|
535 |
-
* Shipping class box
|
536 |
-
*
|
537 |
-
* @since 1.1.2
|
538 |
-
*/
|
539 |
-
public static function shipping_class_box( $product_meta, $id, $product_type = null ){
|
540 |
-
|
541 |
-
$product = wc_get_product( $id );
|
542 |
-
|
543 |
-
if( $product_type == 'variation' ){
|
544 |
-
$label = _e( 'Same as parent', 'woocommerce-stock-manager' );
|
545 |
-
}else{
|
546 |
-
$label = _e( 'No shipping class', 'woocommerce-stock-manager' );
|
547 |
-
}
|
548 |
-
|
549 |
-
$args = array(
|
550 |
-
'taxonomy' => 'product_shipping_class',
|
551 |
-
'hide_empty' => 0,
|
552 |
-
'show_option_none' => __( $label, 'woocommerce' ),
|
553 |
-
'name' => 'shipping_class['.$id.']',
|
554 |
-
'id' => 'shipping_class',
|
555 |
-
'selected' => $product->get_shipping_class_id( 'edit' ),
|
556 |
-
'class' => 'select short shipping_class'.$id,
|
557 |
-
);
|
558 |
-
?>
|
559 |
-
<td>
|
560 |
-
<?php
|
561 |
-
wp_dropdown_categories( $args );
|
562 |
-
?>
|
563 |
-
</td>
|
564 |
-
<?php
|
565 |
-
}
|
566 |
-
|
567 |
-
/**
|
568 |
-
* Price box
|
569 |
-
*
|
570 |
-
* @since 1.1.2
|
571 |
-
*/
|
572 |
-
public static function price_box( $product_meta, $id, $product_type = null ){
|
573 |
-
|
574 |
-
if( $product_type != null && $product_type == 'variable' ){
|
575 |
-
?>
|
576 |
-
<td></td>
|
577 |
-
<?php
|
578 |
-
} else {
|
579 |
-
?>
|
580 |
-
<td>
|
581 |
-
<input class="line-price regular_price_<?php echo $id; ?>" name="regular_price[<?php echo $id; ?>]" type="number" min="<?php echo wsm_get_step(); ?>" step="<?php echo wsm_get_step(); ?>" <?php if(!empty($product_meta['_regular_price'][0])){ echo 'value="'.$product_meta['_regular_price'][0].'"'; } ?> />
|
582 |
-
</td>
|
583 |
-
<?php
|
584 |
-
}
|
585 |
-
}
|
586 |
-
|
587 |
-
/**
|
588 |
-
* Sales Price box
|
589 |
-
*
|
590 |
-
* @since 1.1.2
|
591 |
-
*/
|
592 |
-
public static function sales_price_box( $product_meta, $id, $product_type = null ){
|
593 |
-
if( $product_type != null && $product_type == 'variable' ){
|
594 |
-
?>
|
595 |
-
<td></td>
|
596 |
-
<?php
|
597 |
-
} else {
|
598 |
-
?>
|
599 |
-
<td>
|
600 |
-
<input class="line-price sales_price_<?php echo $id; ?>" name="sales_price[<?php echo $id; ?>]" type="number" min="<?php echo wsm_get_step(); ?>" step="<?php echo wsm_get_step(); ?>" <?php if(!empty($product_meta['_sale_price'][0])){ echo 'value="'.$product_meta['_sale_price'][0].'"'; } ?> />
|
601 |
-
</td>
|
602 |
-
<?php
|
603 |
-
}
|
604 |
-
}
|
605 |
-
|
606 |
-
/**
|
607 |
-
* Weight box
|
608 |
-
*
|
609 |
-
* @since 1.1.2
|
610 |
-
*/
|
611 |
-
public static function weight_box($product_meta, $id){
|
612 |
-
?>
|
613 |
-
<td>
|
614 |
-
<input class="line-price weight_<?php echo $id; ?> wc_input_decimal" name="weight[<?php echo $id; ?>]" <?php if(!empty($product_meta['_weight'][0])){ echo 'value="'.$product_meta['_weight'][0].'"'; } ?> />
|
615 |
-
</td>
|
616 |
-
<?php
|
617 |
-
}
|
618 |
-
|
619 |
-
/**
|
620 |
-
* Manage stock box
|
621 |
-
*
|
622 |
-
* @since 1.1.2
|
623 |
-
*/
|
624 |
-
public static function manage_stock_box($product_meta, $item){
|
625 |
-
?>
|
626 |
-
<td>
|
627 |
-
<select name="manage_stock[<?php echo $item; ?>]" class="manage_stock_<?php echo $item; ?> manage_stock_select" data-item="<?php echo $item; ?>">
|
628 |
-
<option value="yes" <?php if(!empty($product_meta['_manage_stock'][0]) && $product_meta['_manage_stock'][0] == 'yes'){ echo 'selected="selected"'; } ?>><?php _e('Yes','woocommerce-stock-manager'); ?></option>
|
629 |
-
<option value="no" <?php if(!empty($product_meta['_manage_stock'][0]) && $product_meta['_manage_stock'][0] == 'no'){ echo 'selected="selected"'; } ?>><?php _e('No','woocommerce-stock-manager'); ?></option>
|
630 |
-
</select>
|
631 |
-
</td>
|
632 |
-
<?php
|
633 |
-
}
|
634 |
-
/**
|
635 |
-
* Stock status box
|
636 |
-
*
|
637 |
-
* @since 1.1.2
|
638 |
-
*/
|
639 |
-
public static function stock_status_box($product_meta, $item){
|
640 |
-
?>
|
641 |
-
<td>
|
642 |
-
<select name="stock_status[<?php echo $item; ?>]" class="stock_status_<?php echo $item; ?> stock_status_select" data-item="<?php echo $item; ?>" <?php if(!empty($product_meta['_manage_stock'][0]) && $product_meta['_manage_stock'][0] == 'yes'){ echo 'disabled'; } ?>>
|
643 |
-
<option value="instock" <?php if(!empty($product_meta['_stock_status'][0]) && $product_meta['_stock_status'][0] == 'instock'){ echo 'selected="selected"'; } ?>><?php _e('In stock','woocommerce-stock-manager'); ?></option>
|
644 |
-
<option value="outofstock" <?php if(!empty($product_meta['_stock_status'][0]) && $product_meta['_stock_status'][0] == 'outofstock'){ echo 'selected="selected"'; } ?>><?php _e('Out of stock','woocommerce-stock-manager'); ?></option>
|
645 |
-
<option value="onbackorder" <?php if(!empty($product_meta['_stock_status'][0]) && $product_meta['_stock_status'][0] == 'onbackorder'){ echo 'selected="selected"'; } ?>><?php _e('On backorder','woocommerce-stock-manager'); ?></option>
|
646 |
-
</select>
|
647 |
-
</td>
|
648 |
-
<?php
|
649 |
-
}
|
650 |
-
/**
|
651 |
-
* Backorders box
|
652 |
-
*
|
653 |
-
* @since 1.1.2
|
654 |
-
*/
|
655 |
-
public static function backorders_box($product_meta, $item){
|
656 |
-
?>
|
657 |
-
<td>
|
658 |
-
<select name="backorders[<?php echo $item; ?>]" class="backorders_<?php echo $item; ?> backorders_select" data-item="<?php echo $item; ?>" <?php if(!empty($product_meta['_manage_stock'][0]) && $product_meta['_manage_stock'][0] == 'no'){ echo 'disabled'; } ?>>
|
659 |
-
<option value="no" <?php if(!empty($product_meta['_backorders'][0]) && $product_meta['_backorders'][0] == 'no'){ echo 'selected="selected"'; } ?>><?php _e('No','woocommerce-stock-manager'); ?></option>
|
660 |
-
<option value="notify" <?php if(!empty($product_meta['_backorders'][0]) && $product_meta['_backorders'][0] == 'notify'){ echo 'selected="selected"'; } ?>><?php _e('Notify','woocommerce-stock-manager'); ?></option>
|
661 |
-
<option value="yes" <?php if(!empty($product_meta['_backorders'][0]) && $product_meta['_backorders'][0] == 'yes'){ echo 'selected="selected"'; } ?>><?php _e('Yes','woocommerce-stock-manager'); ?></option>
|
662 |
-
</select>
|
663 |
-
</td>
|
664 |
-
<?php
|
665 |
-
}
|
666 |
-
|
667 |
-
/**
|
668 |
-
* Qty box
|
669 |
-
*
|
670 |
-
* @since 1.1.2
|
671 |
-
*/
|
672 |
-
public static function qty_box($product_meta, $item, $product){
|
673 |
-
|
674 |
-
$step = get_option( 'woocommerce_stock_qty_step' );
|
675 |
-
if( empty( $step ) ){ $step = '1'; }
|
676 |
-
|
677 |
-
$class = '';
|
678 |
-
if( !empty( $product ) ){
|
679 |
-
$stock_number = $product->get_stock_quantity();
|
680 |
-
$class = self::get_stock_qty_class( $stock_number );
|
681 |
-
}else{
|
682 |
-
$class = '';
|
683 |
-
$stock_number = '0';
|
684 |
-
}
|
685 |
-
if( empty( $stock_number ) ){ $stock_number = 0; }
|
686 |
-
$_product = wc_get_product( $item );
|
687 |
-
$product_type = $_product->get_type();
|
688 |
-
if( $product_type == 'variable' ){
|
689 |
-
|
690 |
-
$variable_stock = get_option( 'woocommerce_stock_variable_stock' );
|
691 |
-
if( !empty( $variable_stock ) && $variable_stock == 'ok' ){
|
692 |
-
?>
|
693 |
-
<td class="td_center <?php echo $class; ?>" style="width:70px;">
|
694 |
-
<input type="number" name="stock[<?php echo $item; ?>]" step="<?php echo $step; ?>" value="<?php echo $stock_number; ?>" class="stock_<?php echo $item; ?> stock_number" data-item="<?php echo $item; ?>" style="width:70px;" <?php if(!empty($product_meta['_manage_stock'][0]) && $product_meta['_manage_stock'][0] == 'no'){ echo 'disabled'; } ?> />
|
695 |
-
</td>
|
696 |
-
<?php
|
697 |
-
}else{
|
698 |
-
//Show count all variations stock.
|
699 |
-
$stock_number = self::get_all_variations_stock( $item );
|
700 |
-
$class = self::get_stock_qty_class( $stock_number );
|
701 |
-
?>
|
702 |
-
<td class="td_center <?php echo $class; ?>" style="width:70px;">
|
703 |
-
<input type="number" name="stock[<?php echo $item; ?>]" step="<?php echo $step; ?>" value="<?php echo $stock_number; ?>" class="stock_<?php echo $item; ?> stock_number" data-item="<?php echo $item; ?>" style="width:70px;background:#ffffff;" disabled="disabled" />
|
704 |
-
</td>
|
705 |
-
<?php
|
706 |
-
}
|
707 |
-
}else{
|
708 |
-
?>
|
709 |
-
<td class="td_center <?php echo $class; ?>" style="width:70px;">
|
710 |
-
<input type="number" name="stock[<?php echo $item; ?>]" step="<?php echo $step; ?>" value="<?php echo $stock_number; ?>" class="stock_<?php echo $item; ?> stock_number" data-item="<?php echo $item; ?>" style="width:70px;" <?php if(!empty($product_meta['_manage_stock'][0]) && $product_meta['_manage_stock'][0] == 'no'){ echo 'disabled'; } ?> />
|
711 |
-
</td>
|
712 |
-
<?php
|
713 |
-
}
|
714 |
-
}
|
715 |
-
|
716 |
-
/**
|
717 |
-
* Line nonce box
|
718 |
-
*
|
719 |
-
* @since 1.1.2
|
720 |
-
*/
|
721 |
-
public static function line_nonce_box($item){
|
722 |
-
?>
|
723 |
-
<input type="hidden" name="wsm-ajax-nonce-<?php echo $item; ?>" class="wsm-ajax-nonce_<?php echo $item; ?>" value="<?php echo wp_create_nonce( 'wsm-ajax-nonce-'.$item ); ?>" />
|
724 |
-
</td>
|
725 |
-
<?php
|
726 |
-
}
|
727 |
-
/**
|
728 |
-
* Line save box
|
729 |
-
*
|
730 |
-
* @since 1.1.2
|
731 |
-
*/
|
732 |
-
public static function line_save_box( $item ){
|
733 |
-
?>
|
734 |
-
<td class="td_center">
|
735 |
-
<span class="btn btn-primary btn-sm save-product" data-product="<?php echo $item; ?>"><?php _e('Save','woocommerce-stock-manager'); ?></span>
|
736 |
-
</td>
|
737 |
-
<?php
|
738 |
-
}
|
739 |
-
|
740 |
-
/**
|
741 |
-
* Line save box
|
742 |
-
*
|
743 |
-
* @since 1.1.8
|
744 |
-
*/
|
745 |
-
public static function get_all_variations_stock( $item ){
|
746 |
-
|
747 |
-
$args = array(
|
748 |
-
'posts_per_page' => -1,
|
749 |
-
'post_type' => 'product_variation',
|
750 |
-
'post_parent' => $item
|
751 |
-
);
|
752 |
-
$variations = get_posts( $args );
|
753 |
-
|
754 |
-
if( !empty( $variations ) ){
|
755 |
-
$stock = 0;
|
756 |
-
foreach( $variations as $variation ){
|
757 |
-
|
758 |
-
$product_meta = get_post_meta( $variation->ID );
|
759 |
-
|
760 |
-
if( !empty( $product_meta['_stock'][0] ) ){
|
761 |
-
|
762 |
-
$stock = $stock + $product_meta['_stock'][0];
|
763 |
-
|
764 |
-
}
|
765 |
-
|
766 |
-
}
|
767 |
-
return $stock;
|
768 |
-
} else {
|
769 |
-
return false;
|
770 |
-
}
|
771 |
-
|
772 |
-
}
|
773 |
-
|
774 |
-
/**
|
775 |
-
* Line save box
|
776 |
-
*
|
777 |
-
* @since 1.1.8
|
778 |
-
*/
|
779 |
-
public static function get_stock_qty_class( $stock ){
|
780 |
-
|
781 |
-
$class = 'outofstock';
|
782 |
-
|
783 |
-
if( $stock < 1 ){
|
784 |
-
$class = 'outofstock';
|
785 |
-
}else{
|
786 |
-
if( $stock < 5 ){
|
787 |
-
$class = 'lowstock';
|
788 |
-
}else{
|
789 |
-
$class = 'instock';
|
790 |
-
}
|
791 |
-
}
|
792 |
-
|
793 |
-
$class = apply_filters( 'woocommerce_stock_manager_qty_class', $class, $stock );
|
794 |
-
|
795 |
-
return $class;
|
796 |
-
|
797 |
-
}
|
798 |
-
|
799 |
-
|
800 |
-
}//End class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/views/admin.php
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* @package woocommerce-stock-manager/admin/views
|
4 |
* @version 2.7.0
|
5 |
*/
|
@@ -11,149 +13,30 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
11 |
$stock = $this->stock();
|
12 |
|
13 |
/**
|
14 |
-
* Save all data
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
-
* Save display option
|
24 |
-
*/
|
25 |
-
|
26 |
-
|
|
|
27 |
}
|
28 |
|
29 |
?>
|
30 |
|
31 |
|
32 |
<div class="wrap">
|
33 |
-
|
34 |
<h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
|
35 |
|
36 |
<div id="woocommerce-stock-manager-app"></div>
|
37 |
|
38 |
-
<?php /*
|
39 |
-
|
40 |
-
<div class="t-col-12">
|
41 |
-
<div class="toret-box box-info">
|
42 |
-
<div class="box-header">
|
43 |
-
<h3 class="box-title"><?php _e('Stock manager','woocommerce-stock-manager'); ?></h3>
|
44 |
-
</div>
|
45 |
-
<div class="box-body">
|
46 |
-
|
47 |
-
<?php include('components/filter.php'); ?>
|
48 |
-
|
49 |
-
<div class="clear"></div>
|
50 |
-
<form method="post" action="" style="position:relative;">
|
51 |
-
<div class="lineloader"></div>
|
52 |
-
<table class="table-bordered">
|
53 |
-
<tr>
|
54 |
-
<?php WCM_Table::table_header_line(); ?>
|
55 |
-
</tr>
|
56 |
-
<?php $products = $stock->get_products( $_GET );
|
57 |
-
|
58 |
-
if( !empty( $products->posts ) ){
|
59 |
-
foreach( $products->posts as $item ){
|
60 |
-
$product_meta = get_post_meta($item->ID);
|
61 |
-
$item_product = wc_get_product($item->ID);
|
62 |
-
$product_type = $item_product->get_type();
|
63 |
-
?>
|
64 |
-
<tr>
|
65 |
-
<?php if($product_type == 'variable'){
|
66 |
-
echo '<td></td>';
|
67 |
-
}else{
|
68 |
-
?>
|
69 |
-
<td class="td_center"><input type="checkbox" name="cd[<?php echo $item->ID; ?>]" /></td>
|
70 |
-
<?php } ?>
|
71 |
-
<?php WCM_Table::hidden_box( $item->ID ); ?>
|
72 |
-
<?php WCM_Table::thumbnail_box( $item->ID ); ?>
|
73 |
-
<?php WCM_Table::sku_box( $product_meta, $item->ID ); ?>
|
74 |
-
<?php WCM_Table::id_box( $item->ID ); ?>
|
75 |
-
<?php WCM_Table::name_box( $item->ID ); ?>
|
76 |
-
<td class="td_center">
|
77 |
-
<?php if($product_type == 'variable'){
|
78 |
-
echo '<span class="btn btn-info btn-sm show-variable" data-variable="'.$item->ID.'">'.__('Show variables','woocommerce-stock-manager').'</span>';
|
79 |
-
}else{
|
80 |
-
echo $product_type;
|
81 |
-
} ?>
|
82 |
-
</td>
|
83 |
-
<td></td>
|
84 |
-
<?php WCM_Table::table_simple_line( $product_meta, $item->ID, $product_type, $item_product ); ?>
|
85 |
-
<?php do_action( 'stock_manager_table_simple_td', $item->ID ); ?>
|
86 |
-
<?php WCM_Table::line_nonce_box( $item->ID ); ?>
|
87 |
-
<?php WCM_Table::line_save_box( $item->ID ); ?>
|
88 |
-
</tr>
|
89 |
-
|
90 |
-
<?php
|
91 |
-
if($product_type == 'variable'){
|
92 |
-
$args = array(
|
93 |
-
'post_parent' => $item->ID,
|
94 |
-
'post_type' => 'product_variation',
|
95 |
-
'numberposts' => -1,
|
96 |
-
'post_status' => 'publish',
|
97 |
-
'order_by' => 'menu_order'
|
98 |
-
);
|
99 |
-
|
100 |
-
//var_dump( $item_product->get_children() );
|
101 |
-
|
102 |
-
$variations_array = $item_product->get_children();
|
103 |
-
foreach($variations_array as $vars){
|
104 |
-
|
105 |
-
$product_meta = get_post_meta($vars);
|
106 |
-
$item_product = wc_get_product($vars);
|
107 |
-
$product_type = 'product variation' ;
|
108 |
-
|
109 |
-
?>
|
110 |
-
<tr class="variation-line variation-item-<?php echo $item->ID; ?>">
|
111 |
-
<td class="td_center"><input type="checkbox" name="cd[<?php echo $vars; ?>]" /></td>
|
112 |
-
<?php WCM_Table::hidden_box( $vars ); ?>
|
113 |
-
<?php WCM_Table::thumbnail_box( $vars ); ?>
|
114 |
-
<?php WCM_Table::sku_box( $product_meta, $vars ); ?>
|
115 |
-
<?php WCM_Table::id_box( $vars ); ?>
|
116 |
-
|
117 |
-
<td><?php
|
118 |
-
foreach($item_product->get_variation_attributes() as $k => $v){
|
119 |
-
$tag = get_term_by('slug', $v, str_replace('attribute_','',$k));
|
120 |
-
if($tag == false ){
|
121 |
-
echo $v.' ';
|
122 |
-
}else{
|
123 |
-
if(is_array($tag)){
|
124 |
-
echo $tag['name'].' ';
|
125 |
-
}else{
|
126 |
-
echo $tag->name.' ';
|
127 |
-
}
|
128 |
-
}
|
129 |
-
}
|
130 |
-
?></td>
|
131 |
-
<td><?php echo $product_type; ?></td>
|
132 |
-
<td><?php echo $item->ID; ?></td>
|
133 |
-
<?php WCM_Table::table_variation_line( $product_meta, $vars, $item_product ); ?>
|
134 |
-
<?php do_action( 'stock_manager_table_variation_td', $vars ); ?>
|
135 |
-
<?php WCM_Table::line_nonce_box($vars); ?>
|
136 |
-
<?php WCM_Table::line_save_box($vars); ?>
|
137 |
-
</tr>
|
138 |
-
<?php
|
139 |
-
}
|
140 |
-
}
|
141 |
-
?>
|
142 |
-
|
143 |
-
<?php }
|
144 |
-
|
145 |
-
}
|
146 |
-
?>
|
147 |
-
|
148 |
-
</table>
|
149 |
-
<div class="clear"></div>
|
150 |
-
<input type="submit" name="save-all" class="btn btn-danger" value="<?php _e('Save all','woocommerce-stock-manager') ?>" />
|
151 |
-
</form>
|
152 |
-
<div class="clear"></div>
|
153 |
-
|
154 |
-
<?php echo $stock->pagination( $products ); ?>
|
155 |
-
</div>
|
156 |
-
</div>
|
157 |
-
*/ ?>
|
158 |
</div>
|
159 |
<?php
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Admin page to mount Stock Manager.
|
4 |
+
*
|
5 |
* @package woocommerce-stock-manager/admin/views
|
6 |
* @version 2.7.0
|
7 |
*/
|
13 |
$stock = $this->stock();
|
14 |
|
15 |
/**
|
16 |
+
* Save all data.
|
17 |
+
*/
|
18 |
+
$product_id = ( ! empty( $_POST['product_id'] ) ) ? wc_clean( wp_unslash( $_POST['product_id'] ) ) : 0; // phpcs:ignore
|
19 |
+
$product = ( ! empty( $_POST ) ) ? wc_clean( wp_unslash( $_POST ) ) : array(); // phpcs:ignore
|
20 |
+
if ( ! empty( $product_id ) ) {
|
21 |
+
$stock->save_all( $product );
|
22 |
+
// add redirect.
|
23 |
}
|
24 |
|
25 |
/**
|
26 |
+
* Save display option.
|
27 |
+
*/
|
28 |
+
$page_filter_display = ( ! empty( $_POST['page-filter-display'] ) ) ? wc_clean( wp_unslash( $_POST['page-filter-display'] ) ) : ''; // phpcs:ignore
|
29 |
+
if ( ! empty( $page_filter_display ) ) {
|
30 |
+
$stock->save_filter_display( $product );
|
31 |
}
|
32 |
|
33 |
?>
|
34 |
|
35 |
|
36 |
<div class="wrap">
|
|
|
37 |
<h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
|
38 |
|
39 |
<div id="woocommerce-stock-manager-app"></div>
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
</div>
|
42 |
<?php
|
admin/views/{class-storeapps-marketplace.php → class-wsm-storeapps-marketplace.php}
RENAMED
@@ -1,12 +1,24 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
// Exit if accessed directly.
|
4 |
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
-
exit;
|
6 |
}
|
7 |
|
|
|
|
|
|
|
8 |
class WSM_StoreApps_Marketplace {
|
9 |
|
|
|
|
|
|
|
10 |
public static function init() {
|
11 |
?>
|
12 |
<style type="text/css">
|
@@ -48,8 +60,8 @@ class WSM_StoreApps_Marketplace {
|
|
48 |
width: 30%
|
49 |
}
|
50 |
.wsm-marketplace .addons-banner-block-item-icon {
|
51 |
-
|
52 |
-
|
53 |
}
|
54 |
.wsm-marketplace .addons-banner-block-item-content {
|
55 |
display: -webkit-box;
|
@@ -73,12 +85,12 @@ class WSM_StoreApps_Marketplace {
|
|
73 |
opacity: 0.7;
|
74 |
}
|
75 |
.wsm-marketplace .addons-banner-block-item-content p {
|
76 |
-
|
77 |
-
|
78 |
}
|
79 |
.wsm-marketplace .addons-wcs-banner-block-image .addons-img {
|
80 |
-
|
81 |
-
|
82 |
}
|
83 |
.wsm-marketplace .addons-banner-block-item-icon {
|
84 |
display: -webkit-box;
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* StoreApps Marketplace.
|
4 |
+
*
|
5 |
+
* @package woocommerce-stock-manager/admin/views/
|
6 |
+
* @version 2.8.0
|
7 |
+
*/
|
8 |
|
9 |
// Exit if accessed directly.
|
10 |
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
+
exit;
|
12 |
}
|
13 |
|
14 |
+
/**
|
15 |
+
* Class for Stock Manager StoreApps Marketplace.
|
16 |
+
*/
|
17 |
class WSM_StoreApps_Marketplace {
|
18 |
|
19 |
+
/**
|
20 |
+
* Function to init and show content on Marketplace.
|
21 |
+
*/
|
22 |
public static function init() {
|
23 |
?>
|
24 |
<style type="text/css">
|
60 |
width: 30%
|
61 |
}
|
62 |
.wsm-marketplace .addons-banner-block-item-icon {
|
63 |
+
background: #f7f7f7;
|
64 |
+
height: 143px
|
65 |
}
|
66 |
.wsm-marketplace .addons-banner-block-item-content {
|
67 |
display: -webkit-box;
|
85 |
opacity: 0.7;
|
86 |
}
|
87 |
.wsm-marketplace .addons-banner-block-item-content p {
|
88 |
+
margin: 0 0 auto;
|
89 |
+
min-height: 10em;
|
90 |
}
|
91 |
.wsm-marketplace .addons-wcs-banner-block-image .addons-img {
|
92 |
+
max-height: 86px;
|
93 |
+
max-width: 97px
|
94 |
}
|
95 |
.wsm-marketplace .addons-banner-block-item-icon {
|
96 |
display: -webkit-box;
|
admin/views/components/filter.php
DELETED
@@ -1,147 +0,0 @@
|
|
1 |
-
|
2 |
-
<ul class="stock-manager-navigation">
|
3 |
-
<li><span class="navigation-filter-default activ"><?php _e('Filter','woocommerce-stock-manager'); ?></span></li>
|
4 |
-
<li><span class="navigation-filter-by-sku"><?php _e('Search by sku','woocommerce-stock-manager'); ?></span></li>
|
5 |
-
<li><span class="navigation-filter-by-title"><?php _e('Search by product name','woocommerce-stock-manager'); ?></span></li>
|
6 |
-
<li><span class="navigation-filter-display"><?php _e('Display setting','woocommerce-stock-manager'); ?></span></li>
|
7 |
-
</ul>
|
8 |
-
|
9 |
-
<div class="clear"></div>
|
10 |
-
|
11 |
-
<div class="stock-filter filter-block active-filter">
|
12 |
-
<form method="get" action="">
|
13 |
-
|
14 |
-
<select name="order-by">
|
15 |
-
<option value=""><?php _e('Order by','woocommerce-stock-manager'); ?></option>
|
16 |
-
<option value="name-asc" <?php if( isset( $_GET['order-by'] ) && $_GET['order-by'] == 'name-asc' ){ echo 'selected="selected"'; } ?>><?php _e('Product name ASC','woocommerce-stock-manager'); ?></option>
|
17 |
-
<option value="name-desc" <?php if( isset( $_GET['order-by'] ) && $_GET['order-by'] == 'name-desc' ){ echo 'selected="selected"'; } ?>><?php _e('Product name DESC','woocommerce-stock-manager'); ?></option>
|
18 |
-
<option value="sku-asc" <?php if( isset( $_GET['order-by'] ) && $_GET['order-by'] == 'sku-asc' ){ echo 'selected="selected"'; } ?>><?php _e('SKU ASC','woocommerce-stock-manager'); ?></option>
|
19 |
-
<option value="sku-desc" <?php if( isset( $_GET['order-by'] ) && $_GET['order-by'] == 'sku-desc' ){ echo 'selected="selected"'; } ?>><?php _e('SKU DESC','woocommerce-stock-manager'); ?></option>
|
20 |
-
</select>
|
21 |
-
|
22 |
-
<select name="product-type">
|
23 |
-
<option value="simple" <?php if(isset($_GET['product-type']) && $_GET['product-type'] == 'simple'){ echo 'selected="selected"'; } ?> ><?php _e('Simple products','woocommerce-stock-manager'); ?></option>
|
24 |
-
<option value="variable" <?php if(isset($_GET['product-type']) && $_GET['product-type'] == 'variable'){ echo 'selected="selected"'; } ?>><?php _e('Products with variation','woocommerce-stock-manager'); ?></option>
|
25 |
-
</select>
|
26 |
-
|
27 |
-
<select name="product-category">
|
28 |
-
<option value="all"><?php _e('All categories','woocommerce-stock-manager'); ?></option>
|
29 |
-
<?php
|
30 |
-
if(isset($_GET['product-category']) && $_GET['product-category'] != 'all' ){
|
31 |
-
echo $stock->products_categories($_GET['product-category']);
|
32 |
-
}else{
|
33 |
-
echo $stock->products_categories();
|
34 |
-
}
|
35 |
-
|
36 |
-
?>
|
37 |
-
</select>
|
38 |
-
|
39 |
-
<select name="manage-stock">
|
40 |
-
<option value=""><?php _e('Manage stock','woocommerce-stock-manager'); ?></option>
|
41 |
-
<option value="no" <?php if( isset( $_GET['manage-stock'] ) && $_GET['manage-stock'] == 'no' ){ echo 'selected="selected"'; } ?>><?php _e('No manage stock','woocommerce-stock-manager'); ?></option>
|
42 |
-
<option value="yes" <?php if( isset( $_GET['manage-stock'] ) && $_GET['manage-stock'] == 'yes' ){ echo 'selected="selected"'; } ?>><?php _e('Yes manage stock','woocommerce-stock-manager'); ?></option>
|
43 |
-
</select>
|
44 |
-
|
45 |
-
<select name="stock-status">
|
46 |
-
<option value=""><?php _e('Stock status','woocommerce-stock-manager'); ?></option>
|
47 |
-
<option value="instock" <?php if( isset( $_GET['stock-status'] ) && $_GET['stock-status'] == 'instock' ){ echo 'selected="selected"'; } ?>><?php _e('In stock','woocommerce-stock-manager'); ?></option>
|
48 |
-
<option value="outofstock" <?php if( isset( $_GET['stock-status'] ) && $_GET['stock-status'] == 'outofstock' ){ echo 'selected="selected"'; } ?>><?php _e('Out of stock','woocommerce-stock-manager'); ?></option>
|
49 |
-
</select>
|
50 |
-
|
51 |
-
<input type="hidden" name="page" value="stock-manager" />
|
52 |
-
<input type="submit" name="show-stock-status" value="<?php _e('Show','woocommerce-stock-manager'); ?>" class="btn btn-info" />
|
53 |
-
</form>
|
54 |
-
<a href="<?php echo admin_url().'admin.php?page=stock-manager'; ?>" class="btn btn-danger"><?php _e('Clear filter','woocommerce-stock-manager'); ?></a>
|
55 |
-
</div>
|
56 |
-
|
57 |
-
<div class="clear"></div>
|
58 |
-
|
59 |
-
<div class="filter-by-sku filter-block">
|
60 |
-
<form method="get" action="">
|
61 |
-
<input type="text" name="sku" class="sku-seach-field" />
|
62 |
-
<input type="hidden" name="page" value="stock-manager" />
|
63 |
-
<input type="submit" name="show-sku-item" value="<?php _e('Search by sku','woocommerce-stock-manager'); ?>" class="btn btn-info" />
|
64 |
-
</form>
|
65 |
-
</div>
|
66 |
-
|
67 |
-
<div class="clear"></div>
|
68 |
-
|
69 |
-
<div class="filter-by-title filter-block">
|
70 |
-
<form method="get" action="">
|
71 |
-
<input type="text" name="product-title" class="title-seach-field" />
|
72 |
-
<input type="hidden" name="page" value="stock-manager" />
|
73 |
-
<input type="submit" name="show-sku-item" value="<?php _e('Search by product name','woocommerce-stock-manager'); ?>" class="btn btn-info" />
|
74 |
-
</form>
|
75 |
-
</div>
|
76 |
-
|
77 |
-
<div class="clear"></div>
|
78 |
-
|
79 |
-
|
80 |
-
<div class="filter-display filter-block">
|
81 |
-
<form method="post" action="">
|
82 |
-
<?php
|
83 |
-
$display_option = get_option( 'wsm_display_option' );
|
84 |
-
if( empty( $display_option ) ){
|
85 |
-
$display_option = array(
|
86 |
-
'thumbnail' => 'no',
|
87 |
-
'price' => 'display',
|
88 |
-
'sales_price' => 'no',
|
89 |
-
'weight' => 'display',
|
90 |
-
'manage_stock' => 'display',
|
91 |
-
'stock_status' => 'display',
|
92 |
-
'backorders' => 'display',
|
93 |
-
'stock' => 'display',
|
94 |
-
'tax_status' => 'no',
|
95 |
-
'tax_class' => 'no',
|
96 |
-
'shipping_class'=> 'no'
|
97 |
-
);
|
98 |
-
update_option( 'wsm_display_option', $display_option, 'no' );
|
99 |
-
}
|
100 |
-
?>
|
101 |
-
<h2><?php _e('Hide or display cells','woocommerce-stock-manager'); ?></h2>
|
102 |
-
<table class="table-bordered">
|
103 |
-
<tr>
|
104 |
-
<td><?php _e('Thumbnail','woocommerce-stock-manager'); ?></td>
|
105 |
-
<td><input type="checkbox" name="thumbnail" <?php if( !empty( $display_option['thumbnail'] ) && $display_option['thumbnail'] == 'display' ){ echo 'checked="checked"'; } ?> value="ok" /></td>
|
106 |
-
<td><?php _e('Price','woocommerce-stock-manager'); ?></td>
|
107 |
-
<td><input type="checkbox" name="price" <?php if( !empty( $display_option['price'] ) && $display_option['price'] == 'display' ){ echo 'checked="checked"'; } ?> value="ok" /></td>
|
108 |
-
<td><?php _e('Sales price','woocommerce-stock-manager'); ?></td>
|
109 |
-
<td><input type="checkbox" name="sales_price" <?php if( !empty( $display_option['sales_price'] ) && $display_option['sales_price'] == 'display' ){ echo 'checked="checked"'; } ?> value="ok" /></td>
|
110 |
-
<td><?php _e('Weight','woocommerce-stock-manager'); ?></td>
|
111 |
-
<td><input type="checkbox" name="weight" <?php if( !empty( $display_option['weight'] ) && $display_option['weight'] == 'display' ){ echo 'checked="checked"'; } ?> value="ok" /></td>
|
112 |
-
<td><?php _e('Manage stock','woocommerce-stock-manager'); ?></td>
|
113 |
-
<td><input type="checkbox" name="manage_stock" <?php if( !empty( $display_option['manage_stock'] ) && $display_option['manage_stock'] == 'display' ){ echo 'checked="checked"'; } ?> value="ok" /></td>
|
114 |
-
<td><?php _e('Stock status','woocommerce-stock-manager'); ?></td>
|
115 |
-
<td><input type="checkbox" name="stock_status" <?php if( !empty( $display_option['stock_status'] ) && $display_option['stock_status'] == 'display' ){ echo 'checked="checked"'; } ?> value="ok" /></td>
|
116 |
-
<td><?php _e('Backorders','woocommerce-stock-manager'); ?></td>
|
117 |
-
<td><input type="checkbox" name="backorders" <?php if( !empty( $display_option['backorders'] ) && $display_option['backorders'] == 'display' ){ echo 'checked="checked"'; } ?> value="ok" /></td>
|
118 |
-
<td><?php _e('Stock','woocommerce-stock-manager'); ?></td>
|
119 |
-
<td><input type="checkbox" name="stock" <?php if( !empty( $display_option['stock'] ) && $display_option['stock'] == 'display' ){ echo 'checked="checked"'; } ?> value="ok" /></td>
|
120 |
-
</tr>
|
121 |
-
<tr>
|
122 |
-
<td><?php _e('Tax status','woocommerce-stock-manager'); ?></td>
|
123 |
-
<td><input type="checkbox" name="tax_status" <?php if( !empty( $display_option['tax_status'] ) && $display_option['tax_status'] == 'display' ){ echo 'checked="checked"'; } ?> value="ok" /></td>
|
124 |
-
<td><?php _e('Tax class','woocommerce-stock-manager'); ?></td>
|
125 |
-
<td><input type="checkbox" name="tax_class" <?php if( !empty( $display_option['tax_class'] ) && $display_option['tax_class'] == 'display' ){ echo 'checked="checked"'; } ?> value="ok" /></td>
|
126 |
-
<td><?php _e('Shipping class','woocommerce-stock-manager'); ?></td>
|
127 |
-
<td><input type="checkbox" name="shipping_class" <?php if( !empty( $display_option['shipping_class'] ) && $display_option['shipping_class'] == 'display' ){ echo 'checked="checked"'; } ?> value="ok" /></td>
|
128 |
-
<td></td>
|
129 |
-
<td></td>
|
130 |
-
<td></td>
|
131 |
-
<td></td>
|
132 |
-
<td></td>
|
133 |
-
<td></td>
|
134 |
-
<td></td>
|
135 |
-
<td></td>
|
136 |
-
<td></td>
|
137 |
-
<td></td>
|
138 |
-
</tr>
|
139 |
-
</table>
|
140 |
-
|
141 |
-
<input type="hidden" name="page-filter-display" value="filter-display" />
|
142 |
-
<input type="submit" name="show-sku-item" value="<?php _e('Save setting','woocommerce-stock-manager'); ?>" class="btn btn-info" />
|
143 |
-
</form>
|
144 |
-
</div>
|
145 |
-
|
146 |
-
<div class="clear"></div>
|
147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/views/import-export.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Import & Export product data
|
4 |
*
|
5 |
* @package woocommerce-stock-manager/admin/views/
|
6 |
-
* @version 2.
|
7 |
*/
|
8 |
|
9 |
if ( ! defined( 'ABSPATH' ) ) {
|
@@ -11,15 +11,23 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
11 |
}
|
12 |
|
13 |
$stock = $this->stock();
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
return $s;
|
|
|
18 |
|
19 |
-
if (preg_match('#[\x7F-\x9F\xBC]#', $s))
|
20 |
-
return iconv('WINDOWS-1250', 'UTF-8', $s);
|
|
|
21 |
|
22 |
-
return iconv('ISO-8859-2', 'UTF-8', $s);
|
23 |
}
|
24 |
|
25 |
?>
|
@@ -110,49 +118,49 @@ function stockautoUTF($s){
|
|
110 |
<div class="t-col-6">
|
111 |
<div class="toret-box box-info">
|
112 |
<div class="box-header">
|
113 |
-
<h3 class="box-title"><?php
|
114 |
</div>
|
115 |
<div class="box-body">
|
116 |
-
<h4><?php
|
117 |
-
<p><?php
|
118 |
-
<p><?php
|
119 |
-
<h3><?php
|
120 |
<table class="table-bordered">
|
121 |
<tr>
|
122 |
-
<td><?php
|
123 |
-
<td><?php
|
124 |
-
<td><?php
|
125 |
-
<td><?php
|
126 |
-
<td><?php
|
127 |
-
<td><?php
|
128 |
-
<td><?php
|
129 |
-
<td><?php
|
130 |
-
<td><?php
|
131 |
</tr>
|
132 |
<tr>
|
133 |
-
<td><?php
|
134 |
-
<td><?php
|
135 |
-
<td><?php
|
136 |
-
<td><?php
|
137 |
-
<td><?php
|
138 |
-
<td><?php
|
139 |
-
<td><?php
|
140 |
-
<td><?php
|
141 |
<td></td>
|
142 |
</tr>
|
143 |
</table>
|
144 |
<ul>
|
145 |
-
<li><strong><?php
|
146 |
-
<li><strong><?php
|
147 |
-
<li><strong><?php
|
148 |
-
<li><strong><?php
|
149 |
-
<li><strong><?php
|
150 |
-
<li><strong><?php
|
151 |
</ul>
|
152 |
<form method="post" action="" class="setting-form" enctype="multipart/form-data">
|
153 |
<table class="table-bordered">
|
154 |
<tr>
|
155 |
-
<th><?php
|
156 |
<td>
|
157 |
<input type="file" name="uploadFile">
|
158 |
</td>
|
@@ -161,73 +169,77 @@ function stockautoUTF($s){
|
|
161 |
<div class="clear"></div>
|
162 |
<input type="hidden" name="upload" value="ok" />
|
163 |
<?php wp_nonce_field( 'sa-wsm-import', 'sa_wsm_nonce' ); ?>
|
164 |
-
<input type="submit" class="btn btn-info" value="<?php
|
165 |
</form>
|
166 |
<?php
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
|
|
214 |
}
|
215 |
-
$row++;
|
216 |
-
|
217 |
}
|
218 |
-
|
219 |
-
}
|
220 |
|
221 |
-
|
222 |
-
|
223 |
}
|
224 |
} else {
|
225 |
-
echo '<
|
226 |
}
|
227 |
} else {
|
228 |
-
|
229 |
}
|
|
|
|
|
230 |
}
|
|
|
231 |
?>
|
232 |
</div>
|
233 |
</div>
|
@@ -236,11 +248,11 @@ function stockautoUTF($s){
|
|
236 |
<div class="t-col-6">
|
237 |
<div class="toret-box box-info">
|
238 |
<div class="box-header">
|
239 |
-
<h3 class="box-title"><?php
|
240 |
</div>
|
241 |
<div class="box-body">
|
242 |
-
<h4><?php
|
243 |
-
<p><a href="#" class="btn btn-danger product-export"><?php
|
244 |
<div class="export-output" style="display:none;"></div>
|
245 |
<div id="csv" style="display:none;"></div>
|
246 |
</div>
|
3 |
* Import & Export product data
|
4 |
*
|
5 |
* @package woocommerce-stock-manager/admin/views/
|
6 |
+
* @version 2.8.0
|
7 |
*/
|
8 |
|
9 |
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
}
|
12 |
|
13 |
$stock = $this->stock();
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Function to convert stock file.
|
17 |
+
*
|
18 |
+
* @param string $s CSV file row headers.
|
19 |
+
* @return converted
|
20 |
+
*/
|
21 |
+
function stock_auto_utf( $s ) {
|
22 |
+
if ( preg_match( '#[\x80-\x{1FF}\x{2000}-\x{3FFF}]#u', $s ) ) {
|
23 |
return $s;
|
24 |
+
}
|
25 |
|
26 |
+
if ( preg_match( '#[\x7F-\x9F\xBC]#', $s ) ) {
|
27 |
+
return iconv( 'WINDOWS-1250', 'UTF-8', $s );
|
28 |
+
}
|
29 |
|
30 |
+
return iconv( 'ISO-8859-2', 'UTF-8', $s );
|
31 |
}
|
32 |
|
33 |
?>
|
118 |
<div class="t-col-6">
|
119 |
<div class="toret-box box-info">
|
120 |
<div class="box-header">
|
121 |
+
<h3 class="box-title"><?php esc_html_e( 'Import', 'woocommerce-stock-manager' ); ?></h3>
|
122 |
</div>
|
123 |
<div class="box-body">
|
124 |
+
<h4><?php esc_html_e( 'You can upload csv file, with your stock data. ', 'woocommerce-stock-manager' ); ?></h4>
|
125 |
+
<p><?php esc_html_e( 'CSV file must be in this format, or you can export file with exist data and edit them. ', 'woocommerce-stock-manager' ); ?></p>
|
126 |
+
<p><?php esc_html_e( 'If you have a lot of products and export/import not working, increase memory limit.. ', 'woocommerce-stock-manager' ); ?></p>
|
127 |
+
<h3><?php esc_html_e( 'File format', 'woocommerce-stock-manager' ); ?></h3>
|
128 |
<table class="table-bordered">
|
129 |
<tr>
|
130 |
+
<td><?php esc_html_e( 'ID', 'woocommerce-stock-manager' ); ?></td>
|
131 |
+
<td><?php esc_html_e( 'SKU', 'woocommerce-stock-manager' ); ?></td>
|
132 |
+
<td><?php esc_html_e( 'Product name', 'woocommerce-stock-manager' ); ?></td>
|
133 |
+
<td><?php esc_html_e( 'Manage stock', 'woocommerce-stock-manager' ); ?></td>
|
134 |
+
<td><?php esc_html_e( 'Stock status', 'woocommerce-stock-manager' ); ?></td>
|
135 |
+
<td><?php esc_html_e( 'Backorders', 'woocommerce-stock-manager' ); ?></td>
|
136 |
+
<td><?php esc_html_e( 'Stock', 'woocommerce-stock-manager' ); ?></td>
|
137 |
+
<td><?php esc_html_e( 'Product type', 'woocommerce-stock-manager' ); ?></td>
|
138 |
+
<td><?php esc_html_e( 'Parent ID', 'woocommerce-stock-manager' ); ?></td>
|
139 |
</tr>
|
140 |
<tr>
|
141 |
+
<td><?php esc_html_e( '123', 'woocommerce-stock-manager' ); ?></td>
|
142 |
+
<td><?php esc_html_e( 'abc111', 'woocommerce-stock-manager' ); ?></td>
|
143 |
+
<td><?php esc_html_e( 'T-shirt', 'woocommerce-stock-manager' ); ?></td>
|
144 |
+
<td><?php esc_html_e( 'yes', 'woocommerce-stock-manager' ); ?></td>
|
145 |
+
<td><?php esc_html_e( 'instock', 'woocommerce-stock-manager' ); ?></td>
|
146 |
+
<td><?php esc_html_e( 'yes', 'woocommerce-stock-manager' ); ?></td>
|
147 |
+
<td><?php esc_html_e( '10', 'woocommerce-stock-manager' ); ?></td>
|
148 |
+
<td><?php esc_html_e( 'simple', 'woocommerce-stock-manager' ); ?></td>
|
149 |
<td></td>
|
150 |
</tr>
|
151 |
</table>
|
152 |
<ul>
|
153 |
+
<li><strong><?php esc_html_e( 'ID', 'woocommerce-stock-manager' ); ?></strong> <?php esc_html_e( 'product id, required. Neccessary for import and export.', 'woocommerce-stock-manager' ); ?></li>
|
154 |
+
<li><strong><?php esc_html_e( 'SKU', 'woocommerce-stock-manager' ); ?></strong> <?php esc_html_e( 'product unique identificator.', 'woocommerce-stock-manager' ); ?></li>
|
155 |
+
<li><strong><?php esc_html_e( 'Manage stock', 'woocommerce-stock-manager' ); ?></strong> <?php esc_html_e( 'values: "yes", "notify", "no". If is empty "no" will be save.', 'woocommerce-stock-manager' ); ?></li>
|
156 |
+
<li><strong><?php esc_html_e( 'Stock status', 'woocommerce-stock-manager' ); ?></strong> <?php esc_html_e( 'values: "instock", "outofstock". If is empty "outofstock" will be save.', 'woocommerce-stock-manager' ); ?></li>
|
157 |
+
<li><strong><?php esc_html_e( 'Backorders', 'woocommerce-stock-manager' ); ?></strong> <?php esc_html_e( 'values: "yes", "notify", "no". If is empty "no" will be save.', 'woocommerce-stock-manager' ); ?></li>
|
158 |
+
<li><strong><?php esc_html_e( 'Stock', 'woocommerce-stock-manager' ); ?></strong> <?php esc_html_e( 'quantity value. If is empty, 0 will be save.', 'woocommerce-stock-manager' ); ?></li>
|
159 |
</ul>
|
160 |
<form method="post" action="" class="setting-form" enctype="multipart/form-data">
|
161 |
<table class="table-bordered">
|
162 |
<tr>
|
163 |
+
<th><?php esc_html_e( 'Upload csv file', 'woocommerce-stock-manager' ); ?></th>
|
164 |
<td>
|
165 |
<input type="file" name="uploadFile">
|
166 |
</td>
|
169 |
<div class="clear"></div>
|
170 |
<input type="hidden" name="upload" value="ok" />
|
171 |
<?php wp_nonce_field( 'sa-wsm-import', 'sa_wsm_nonce' ); ?>
|
172 |
+
<input type="submit" class="btn btn-info" value="<?php esc_html_e( 'Upload', 'woocommerce-stock-manager' ); ?>" />
|
173 |
</form>
|
174 |
<?php
|
175 |
+
if ( isset( $_POST['upload'] ) && ! empty( $_FILES ) ) {
|
176 |
+
$post_sa_wsm_nonce = ( ! empty( $_POST['sa_wsm_nonce'] ) ) ? wc_clean( wp_unslash( $_POST['sa_wsm_nonce'] ) ) : ''; // phpcs:ignore
|
177 |
+
if ( ! empty( $post_sa_wsm_nonce ) && wp_verify_nonce( $post_sa_wsm_nonce, 'sa-wsm-import' ) ) {
|
178 |
+
// Allowed filetypes for import.
|
179 |
+
$valid_filetypes = array(
|
180 |
+
'csv' => 'text/csv',
|
181 |
+
);
|
182 |
+
|
183 |
+
// Retrieve the file type from the file name.
|
184 |
+
$uploaded_file = $_FILES['uploadFile']['name']; // phpcs:ignore
|
185 |
+
$filetype = wp_check_filetype( wc_clean( wp_unslash( $uploaded_file ) ), $valid_filetypes );
|
186 |
+
|
187 |
+
// Check if file type is valid.
|
188 |
+
if ( in_array( $filetype['type'], $valid_filetypes, true ) ) {
|
189 |
+
$target_dir = STOCKDIR . 'admin/views/upload/';
|
190 |
+
$target_dir = $target_dir . basename( $uploaded_file );
|
191 |
+
|
192 |
+
if ( move_uploaded_file( $_FILES['uploadFile']['tmp_name'], $target_dir ) ) { // phpcs:ignore
|
193 |
+
|
194 |
+
/* translators: 1: Uploaded file name */
|
195 |
+
echo sprintf( esc_html__( 'The file %1$s has been uploaded', 'woocommerce-stock-manager' ), basename( $uploaded_file ) ); // phpcs:ignore
|
196 |
+
|
197 |
+
$row = 1;
|
198 |
+
$handle = fopen( $target_dir, 'r' ); // phpcs:ignore
|
199 |
+
if ( false !== $handle ) {
|
200 |
+
|
201 |
+
// assigning to $data to not consider first row of CSV file.
|
202 |
+
while ( ( $data = fgetcsv( $handle, 1000, ',' ) ) !== false ) { // phpcs:ignore
|
203 |
+
$num = count( $data );
|
204 |
+
|
205 |
+
$product_id = stock_auto_utf( $data[0] );
|
206 |
+
$sku = stock_auto_utf( $data[1] );
|
207 |
+
$manage_stock = stock_auto_utf( $data[3] );
|
208 |
+
$stock_status = stock_auto_utf( $data[4] );
|
209 |
+
$backorders = stock_auto_utf( $data[5] );
|
210 |
+
$stock = stock_auto_utf( $data[6] );
|
211 |
+
|
212 |
+
if ( 1 !== $row ) {
|
213 |
+
if ( ! empty( $product_id ) ) {
|
214 |
+
$values = array(
|
215 |
+
'sku' => $sku,
|
216 |
+
'manage_stock' => $manage_stock,
|
217 |
+
'stock_status' => $stock_status,
|
218 |
+
'backorders' => $backorders,
|
219 |
+
'stock' => $stock,
|
220 |
+
);
|
221 |
+
|
222 |
+
WSM_Save::save_one_item( $values, $product_id );
|
223 |
+
|
224 |
+
/* translators: 1: P tag opening 2: Updated Product ID 3. Closing p tag */
|
225 |
+
echo sprintf( esc_html__( '%1$s Product with ID %2$s was updated. %3$s', 'woocommerce-stock-manager' ), '<p>', wp_kses_post( $product_id ), '</p>' );
|
226 |
}
|
|
|
|
|
227 |
}
|
228 |
+
$row++;
|
|
|
229 |
|
230 |
+
}
|
231 |
+
fclose( $handle ); // phpcs:ignore
|
232 |
}
|
233 |
} else {
|
234 |
+
echo '<p>' . esc_html__( 'Sorry, there was an error uploading your file.', 'woocommerce-stock-manager' ) . '</p>';
|
235 |
}
|
236 |
} else {
|
237 |
+
echo '<h3 class="wsm-upload-failed">' . esc_html__( 'Error: You have not uploaded a CSV file.', 'woocommerce-stock-manager' ) . '</h3>';
|
238 |
}
|
239 |
+
} else {
|
240 |
+
wp_die( 'Could not verify nonce' );
|
241 |
}
|
242 |
+
}
|
243 |
?>
|
244 |
</div>
|
245 |
</div>
|
248 |
<div class="t-col-6">
|
249 |
<div class="toret-box box-info">
|
250 |
<div class="box-header">
|
251 |
+
<h3 class="box-title"><?php esc_html_e( 'Export', 'woocommerce-stock-manager' ); ?></h3>
|
252 |
</div>
|
253 |
<div class="box-body">
|
254 |
+
<h4><?php esc_html_e( 'You can download csv file, with your stock data. ', 'woocommerce-stock-manager' ); ?></h4>
|
255 |
+
<p><a href="#" class="btn btn-danger product-export"><?php esc_html_e( 'Create export file', 'woocommerce-stock-manager' ); ?></a></p>
|
256 |
<div class="export-output" style="display:none;"></div>
|
257 |
<div id="csv" style="display:none;"></div>
|
258 |
</div>
|
admin/views/index.php
CHANGED
@@ -1 +1,10 @@
|
|
1 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silence is golden
|
4 |
+
*
|
5 |
+
* @package woocommerce-stock-manager/admin/views/
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
admin/views/log-history.php
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* @package woocommerce-stock-manager/admin/views/
|
4 |
-
* @version 2.
|
5 |
*/
|
6 |
|
7 |
if ( ! defined( 'ABSPATH' ) ) {
|
@@ -9,10 +11,12 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
9 |
}
|
10 |
|
11 |
global $wpdb;
|
12 |
-
|
13 |
-
if( !empty( $
|
14 |
-
$product_id = sanitize_text_field( $_GET['history'] );
|
15 |
$product = wc_get_product( $product_id );
|
|
|
|
|
|
|
16 |
} else {
|
17 |
return;
|
18 |
}
|
@@ -23,42 +27,48 @@ if( !empty( $_GET['history'] ) ){
|
|
23 |
<div class="t-col-12">
|
24 |
<div class="toret-box box-info">
|
25 |
<div class="box-header">
|
26 |
-
<h3 class="box-title"><?php echo $product->get_name(); ?></h3>
|
27 |
</div>
|
28 |
<div class="box-body">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
?>
|
43 |
-
|
44 |
-
<td>
|
45 |
-
<?php
|
46 |
-
$offset = get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
|
47 |
-
echo date_i18n('F j, Y @ h:i A', ( strtotime($item->date_created) + $offset ) );
|
48 |
-
?>
|
49 |
-
</td>
|
50 |
-
<td><?php echo intval($item->qty); ?></td>
|
51 |
-
</tr>
|
52 |
<?php
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
}else{
|
58 |
-
echo '<p>'.__( 'No result', 'woocommerce-stock-manager' ).'</p>';
|
59 |
-
}
|
60 |
-
?>
|
61 |
-
|
62 |
</div>
|
63 |
</div>
|
64 |
</div>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Stock Log History detailed page.
|
4 |
+
*
|
5 |
* @package woocommerce-stock-manager/admin/views/
|
6 |
+
* @version 2.8.0
|
7 |
*/
|
8 |
|
9 |
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
}
|
12 |
|
13 |
global $wpdb;
|
14 |
+
$product_id = ( ! empty( $_GET['product-history'] ) ) ? intval( wc_clean( wp_unslash( $_GET['product-history'] ) ) ) : 0; // phpcs:ignore
|
15 |
+
if ( ! empty( $product_id ) ) {
|
|
|
16 |
$product = wc_get_product( $product_id );
|
17 |
+
if ( ! $product instanceof WC_Product ) {
|
18 |
+
return;
|
19 |
+
}
|
20 |
} else {
|
21 |
return;
|
22 |
}
|
27 |
<div class="t-col-12">
|
28 |
<div class="toret-box box-info">
|
29 |
<div class="box-header">
|
30 |
+
<h3 class="box-title"><?php echo wp_kses_post( $product->get_name() ); ?></h3>
|
31 |
</div>
|
32 |
<div class="box-body">
|
33 |
+
<?php
|
34 |
+
$data = $wpdb->get_results( // phpcs:ignore
|
35 |
+
$wpdb->prepare( // phpcs:ignore
|
36 |
+
"SELECT *
|
37 |
+
FROM {$wpdb->prefix}stock_log
|
38 |
+
WHERE product_id = %d",
|
39 |
+
$product_id
|
40 |
+
)
|
41 |
+
);
|
42 |
|
43 |
+
if ( ! empty( $data ) ) {
|
44 |
+
?>
|
45 |
+
<div class="clear"></div>
|
46 |
+
<table class="table-bordered">
|
47 |
+
<tr>
|
48 |
+
<th><?php esc_html_e( 'Date', 'woocommerce-stock-manager' ); ?></th>
|
49 |
+
<th><?php esc_html_e( 'Stock', 'woocommerce-stock-manager' ); ?></th>
|
50 |
+
</tr>
|
51 |
+
<?php
|
52 |
+
foreach ( $data as $item ) {
|
53 |
+
?>
|
54 |
+
<tr>
|
55 |
+
<td>
|
56 |
+
<?php
|
57 |
+
$offset = get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
|
58 |
+
echo esc_html( date_i18n( 'F j, Y @ h:i A', ( strtotime( $item->date_created ) + $offset ) ) );
|
59 |
+
?>
|
60 |
+
</td>
|
61 |
+
<td><?php echo intval( $item->qty ); ?></td>
|
62 |
+
</tr>
|
63 |
+
<?php
|
64 |
+
}
|
65 |
?>
|
66 |
+
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
<?php
|
68 |
+
} else {
|
69 |
+
echo '<p>' . esc_html__( 'No result', 'woocommerce-stock-manager' ) . '</p>';
|
70 |
+
}
|
71 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
72 |
</div>
|
73 |
</div>
|
74 |
</div>
|
admin/views/log.php
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* @package woocommerce-stock-manager/admin/views/
|
4 |
-
* @version 2.
|
5 |
*/
|
6 |
|
7 |
if ( ! defined( 'ABSPATH' ) ) {
|
@@ -17,85 +19,90 @@ $stock = $this->stock();
|
|
17 |
<div class="t-col-12">
|
18 |
<div class="toret-box box-info">
|
19 |
<div class="box-header">
|
20 |
-
<h3 class="box-title"
|
21 |
</div>
|
22 |
<div class="box-body">
|
23 |
-
<?php
|
24 |
-
// include('components/filter.php');
|
25 |
-
?>
|
26 |
<div class="clear"></div>
|
27 |
<table class="table-bordered">
|
28 |
<tr>
|
29 |
-
<th><?php
|
30 |
-
<th><?php
|
31 |
-
<th><?php
|
32 |
-
<th><?php
|
33 |
-
<th><?php
|
34 |
-
<th><?php
|
35 |
<th></th>
|
36 |
</tr>
|
37 |
-
<?php
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
43 |
<tr>
|
44 |
-
<td><?php echo $item_product->
|
45 |
-
<td><?php echo $item_product->
|
46 |
<td>
|
47 |
-
<a href="<?php echo admin_url().'post.php?post='
|
48 |
-
|
49 |
</a>
|
50 |
</td>
|
51 |
-
<td class="td_center"><?php echo $product_type; ?></td>
|
52 |
<td></td>
|
53 |
-
<td class="td_center"><?php echo $item_product->get_stock_quantity(); ?></td>
|
54 |
<td class="td_center">
|
55 |
-
|
56 |
-
<a class="btn btn-success" href="<?php echo admin_url().'admin.php?page=stock-manager-log&history='
|
57 |
<?php } ?>
|
58 |
</td>
|
59 |
</tr>
|
60 |
-
<?php
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
75 |
<tr>
|
76 |
-
<td><?php echo $item_product->
|
77 |
-
<td><?php echo $item_product->
|
78 |
<td>
|
79 |
-
<a href="<?php echo admin_url().'post.php?post='
|
80 |
-
|
81 |
</a>
|
82 |
</td>
|
83 |
-
<td class="td_center"><?php echo $product_type; ?></td>
|
84 |
-
<td><?php echo $item->ID; ?></td>
|
85 |
-
<td class="td_center"><?php echo $item_product->get_stock_quantity(); ?></td>
|
86 |
<td class="td_center">
|
87 |
-
<a class="btn btn-success" href="<?php echo admin_url().'admin.php?page=stock-manager-log&history='
|
88 |
</td>
|
89 |
</tr>
|
90 |
<?php
|
91 |
-
}
|
92 |
}
|
93 |
-
|
94 |
}
|
|
|
95 |
?>
|
96 |
</table>
|
97 |
<div class="clear"></div>
|
98 |
-
<?php echo $stock->pagination( $products ); ?>
|
99 |
</div>
|
100 |
</div>
|
101 |
</div>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Stock Log page.
|
4 |
+
*
|
5 |
* @package woocommerce-stock-manager/admin/views/
|
6 |
+
* @version 2.8.0
|
7 |
*/
|
8 |
|
9 |
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
<div class="t-col-12">
|
20 |
<div class="toret-box box-info">
|
21 |
<div class="box-header">
|
22 |
+
<h3 class="box-title"></h3>
|
23 |
</div>
|
24 |
<div class="box-body">
|
|
|
|
|
|
|
25 |
<div class="clear"></div>
|
26 |
<table class="table-bordered">
|
27 |
<tr>
|
28 |
+
<th><?php esc_html_e( 'Product ID', 'woocommerce-stock-manager' ); ?></th>
|
29 |
+
<th><?php esc_html_e( 'SKU', 'woocommerce-stock-manager' ); ?></th>
|
30 |
+
<th><?php esc_html_e( 'Name', 'woocommerce-stock-manager' ); ?></th>
|
31 |
+
<th><?php esc_html_e( 'Product type', 'woocommerce-stock-manager' ); ?></th>
|
32 |
+
<th><?php esc_html_e( 'Parent ID', 'woocommerce-stock-manager' ); ?></th>
|
33 |
+
<th><?php esc_html_e( 'Stock', 'woocommerce-stock-manager' ); ?></th>
|
34 |
<th></th>
|
35 |
</tr>
|
36 |
+
<?php
|
37 |
+
$get = ( ! empty( $_GET ) ) ? wc_clean( wp_unslash( $_GET ) ) : array(); // phpcs:ignore
|
38 |
+
$products = ( ! empty( $get ) ) ? $stock->get_products( $get ) : array();
|
39 |
+
if ( ! empty( $products->posts ) ) {
|
40 |
+
foreach ( $products->posts as $item ) {
|
41 |
+
$item_product = wc_get_product( $item->ID );
|
42 |
+
if ( ! $item_product instanceof WC_Product ) {
|
43 |
+
continue;
|
44 |
+
}
|
45 |
+
$product_type = $item_product->get_type();
|
46 |
+
?>
|
47 |
<tr>
|
48 |
+
<td class="td_center"><?php echo esc_html( $item_product->get_id() ); ?></td>
|
49 |
+
<td><?php echo esc_html( $item_product->get_sku() ); ?></td>
|
50 |
<td>
|
51 |
+
<a href="<?php echo esc_url( admin_url() . 'post.php?post=' . $item_product->get_id() . '&action=edit' ); ?>" target="_blank">
|
52 |
+
<?php echo wp_kses_post( get_the_title( $item_product->get_id() ) ); ?>
|
53 |
</a>
|
54 |
</td>
|
55 |
+
<td class="td_center"><?php echo esc_html( $product_type ); ?></td>
|
56 |
<td></td>
|
57 |
+
<td class="td_center"><?php echo esc_html( $item_product->get_stock_quantity() ); ?></td>
|
58 |
<td class="td_center">
|
59 |
+
<?php if ( 'variable' !== $product_type ) { ?>
|
60 |
+
<a class="btn btn-success" href="<?php echo esc_url( admin_url() . 'admin.php?page=stock-manager-log&product-history=' . $item_product->get_id() ); ?>"><?php esc_html_e( 'History', 'woocommerce-stock-manager' ); ?></a>
|
61 |
<?php } ?>
|
62 |
</td>
|
63 |
</tr>
|
64 |
+
<?php
|
65 |
+
if ( 'variable' === $product_type ) {
|
66 |
+
$args = array(
|
67 |
+
'post_parent' => $item->ID,
|
68 |
+
'post_type' => 'product_variation',
|
69 |
+
'numberposts' => -1,
|
70 |
+
'post_status' => 'publish',
|
71 |
+
'order_by' => 'menu_order',
|
72 |
+
);
|
73 |
|
74 |
+
$variations_array = $item_product->get_children();
|
75 |
+
foreach ( $variations_array as $vars ) {
|
76 |
+
$item_product = wc_get_product( $vars );
|
77 |
+
if ( ! $item_product instanceof WC_Product ) {
|
78 |
+
continue;
|
79 |
+
}
|
80 |
+
$product_type = 'product variation';
|
81 |
+
?>
|
82 |
<tr>
|
83 |
+
<td class="td_center"><?php echo esc_html( $item_product->get_id() ); ?></td>
|
84 |
+
<td><?php echo esc_html( $item_product->get_sku() ); ?></td>
|
85 |
<td>
|
86 |
+
<a href="<?php echo esc_url( admin_url() . 'post.php?post=' . $item_product->get_parent_id() . '&action=edit' ); ?>" target="_blank">
|
87 |
+
<?php echo wp_kses_post( get_the_title( $item_product->get_id() ) ); ?>
|
88 |
</a>
|
89 |
</td>
|
90 |
+
<td class="td_center"><?php echo esc_html( $product_type ); ?></td>
|
91 |
+
<td class="td_center"><?php echo esc_html( $item->ID ); ?></td>
|
92 |
+
<td class="td_center"><?php echo esc_html( $item_product->get_stock_quantity() ); ?></td>
|
93 |
<td class="td_center">
|
94 |
+
<a class="btn btn-success" href="<?php echo esc_url( admin_url() . 'admin.php?page=stock-manager-log&product-history=' . $item_product->get_id() ); ?>"><?php esc_html_e( 'History', 'woocommerce-stock-manager' ); ?></a>
|
95 |
</td>
|
96 |
</tr>
|
97 |
<?php
|
|
|
98 |
}
|
99 |
+
}
|
100 |
}
|
101 |
+
}
|
102 |
?>
|
103 |
</table>
|
104 |
<div class="clear"></div>
|
105 |
+
<?php echo wp_kses_post( $stock->pagination( $products ) ); ?>
|
106 |
</div>
|
107 |
</div>
|
108 |
</div>
|
admin/views/setting.php
CHANGED
@@ -1,40 +1,50 @@
|
|
1 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
7 |
delete_option( 'woocommerce_stock_old_styles' );
|
8 |
}
|
9 |
}
|
10 |
|
11 |
-
$old_styles = get_option( 'woocommerce_stock_old_styles' );
|
12 |
-
if( empty( $old_styles ) ){ $old_styles = 'no'; }
|
13 |
?>
|
14 |
|
15 |
<div class="wrap">
|
16 |
-
|
17 |
<h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
|
18 |
-
|
19 |
<div class="t-col-6">
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
38 |
</div>
|
39 |
</div>
|
40 |
<?php
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Setting page.
|
4 |
+
*
|
5 |
+
* @package woocommerce-stock-manager/admin/views/
|
6 |
+
* @version 2.8.0
|
7 |
+
*/
|
8 |
|
9 |
+
$save = ( ! empty( $_POST['save'] ) ) ? wc_clean( wp_unslash( $_POST['save'] ) ) : ''; // phpcs:ignore
|
10 |
+
if ( ! empty( $save ) ) {
|
11 |
+
$old_styles = ( ! empty( $_POST['old_styles'] ) ) ? wc_clean( wp_unslash( $_POST['old_styles'] ) ) : ''; // phpcs:ignore
|
12 |
+
if ( ! empty( $old_styles ) ) {
|
13 |
+
update_option( 'woocommerce_stock_old_styles', $old_styles, 'no' );
|
14 |
+
} else {
|
15 |
delete_option( 'woocommerce_stock_old_styles' );
|
16 |
}
|
17 |
}
|
18 |
|
19 |
+
$old_styles = get_option( 'woocommerce_stock_old_styles', 'no' );
|
|
|
20 |
?>
|
21 |
|
22 |
<div class="wrap">
|
|
|
23 |
<h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
|
|
|
24 |
<div class="t-col-6">
|
25 |
+
<div class="toret-box box-info">
|
26 |
+
<div class="box-header">
|
27 |
+
<h3 class="box-title"></h3>
|
28 |
+
</div>
|
29 |
+
<div class="box-body">
|
30 |
+
<div class="clear"></div>
|
31 |
+
<form method="post" action="" style="position:relative;">
|
32 |
+
<table class="table-bordered">
|
33 |
+
<tr>
|
34 |
+
<th><?php esc_html_e( 'Active old styles', 'woocommerce-stock-manager' ); ?></th>
|
35 |
+
<td><input type="checkbox" name="old_styles" value="ok"
|
36 |
+
<?php
|
37 |
+
if ( 'ok' === $old_styles ) {
|
38 |
+
echo 'checked="checked"'; }
|
39 |
+
?>
|
40 |
+
/></td>
|
41 |
+
</tr>
|
42 |
+
</table>
|
43 |
+
<br>
|
44 |
+
<input type="submit" name="save" class="btn btn-danger" />
|
45 |
+
</form>
|
46 |
+
</div>
|
47 |
+
</div>
|
48 |
</div>
|
49 |
</div>
|
50 |
<?php
|
admin/views/stock-monitor.php
DELETED
@@ -1,57 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if( isset( $_POST['save'] ) ){
|
4 |
-
if( isset( $_POST['limit'] ) ){
|
5 |
-
update_option( 'woocommerce_stock_limit', sanitize_text_field( $_POST['limit'] ), 'no' );
|
6 |
-
}
|
7 |
-
if( isset( $_POST['variable'] ) ){
|
8 |
-
update_option( 'woocommerce_stock_variable_stock', sanitize_text_field( $_POST['variable'] ), 'no' );
|
9 |
-
}else{
|
10 |
-
delete_option( 'woocommerce_stock_variable_stock' );
|
11 |
-
}
|
12 |
-
if( isset( $_POST['step'] ) ){
|
13 |
-
update_option( 'woocommerce_stock_qty_step', sanitize_text_field( $_POST['step'] ), 'no' );
|
14 |
-
}
|
15 |
-
}
|
16 |
-
|
17 |
-
$limit = get_option( 'woocommerce_stock_limit' );
|
18 |
-
if( empty( $limit ) ){ $limit = 100; }
|
19 |
-
$variable = get_option( 'woocommerce_stock_variable_stock' );
|
20 |
-
if( empty( $variable ) ){ $variable = 'no'; }
|
21 |
-
$step = get_option( 'woocommerce_stock_qty_step' );
|
22 |
-
if( empty( $step ) ){ $step = '1'; }
|
23 |
-
?>
|
24 |
-
|
25 |
-
<div class="wrap">
|
26 |
-
|
27 |
-
<h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
|
28 |
-
|
29 |
-
<div class="t-col-6">
|
30 |
-
<div class="toret-box box-info">
|
31 |
-
<div class="box-header">
|
32 |
-
<h3 class="box-title"><?php _e('Stock manager setting','woocommerce-stock-manager'); ?></h3>
|
33 |
-
</div>
|
34 |
-
<div class="box-body">
|
35 |
-
<div class="clear"></div>
|
36 |
-
<form method="post" action="" style="position:relative;">
|
37 |
-
<table class="table-bordered">
|
38 |
-
<tr>
|
39 |
-
<th><?php _e('Products limit','woocommerce-stock-manager'); ?></th>
|
40 |
-
<td><input type="number" name="limit" value="<?php echo $limit; ?>" start="1" step="1" /></td>
|
41 |
-
</tr>
|
42 |
-
<tr>
|
43 |
-
<th><?php _e('Allow stock for variable products','woocommerce-stock-manager'); ?></th>
|
44 |
-
<td><input type="checkbox" name="variable" value="ok" <?php if( $variable == 'ok' ){ echo 'checked="checked"'; } ?> /></td>
|
45 |
-
</tr>
|
46 |
-
<tr>
|
47 |
-
<th><?php _e('Qty input step','woocommerce-stock-manager'); ?></th>
|
48 |
-
<td><input type="text" name="step" value="<?php echo $step; ?>" /></td>
|
49 |
-
</tr>
|
50 |
-
</table>
|
51 |
-
<input type="submit" name="save" class="btn btn-danger" />
|
52 |
-
</form>
|
53 |
-
</div>
|
54 |
-
</div>
|
55 |
-
</div>
|
56 |
-
</div>
|
57 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
index.php
CHANGED
@@ -1 +1,10 @@
|
|
1 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silence is golden
|
4 |
+
*
|
5 |
+
* @package woocommerce-stock-manager
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
languages/index.php
CHANGED
@@ -1 +1,10 @@
|
|
1 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silence is golden
|
4 |
+
*
|
5 |
+
* @package woocommerce-stock-manager/languages/
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
languages/woocommerce-stock-manager.pot
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
# This file is distributed under the same license as the Stock Manager for WooCommerce plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Stock Manager for WooCommerce 2.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woocommerce-stock-manager\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"POT-Creation-Date: 2021-09-
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
"X-Generator: WP-CLI 2.1.0\n"
|
15 |
"X-Domain: woocommerce-stock-manager\n"
|
@@ -34,452 +34,277 @@ msgstr ""
|
|
34 |
msgid "https://www.storeapps.org/"
|
35 |
msgstr ""
|
36 |
|
37 |
-
#: admin/
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
#: admin/
|
42 |
-
#: admin/
|
43 |
-
#: admin/views/import-export.php:
|
44 |
-
#: admin/views/import-export.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
#: admin/views/log.php:29
|
|
|
|
|
46 |
#: admin/assets/src/components/ProductFilter.js:64
|
47 |
#: admin/assets/src/components/Products.js:99
|
48 |
#: admin/assets/src/components/ScreenOptions.js:38
|
49 |
msgid "SKU"
|
50 |
msgstr ""
|
51 |
|
52 |
-
#: admin/includes/config.php:11
|
53 |
-
#: admin/includes/wcm-class-table.php:252
|
54 |
-
#: admin/views/import-export.php:122
|
55 |
-
#: admin/views/import-export.php:145
|
56 |
#: admin/views/log.php:30
|
57 |
-
|
58 |
-
msgid "ID"
|
59 |
msgstr ""
|
60 |
|
61 |
-
#: admin/
|
62 |
-
#: admin/views/
|
63 |
-
#: admin/assets/src/components/Products.js:
|
64 |
-
|
65 |
-
msgid "Tax status"
|
66 |
msgstr ""
|
67 |
|
68 |
-
#: admin/
|
69 |
-
#: admin/views/
|
70 |
-
|
71 |
-
#: admin/assets/src/components/ScreenOptions.js:93
|
72 |
-
msgid "Tax class"
|
73 |
msgstr ""
|
74 |
|
75 |
-
#: admin/
|
76 |
-
#: admin/views/
|
77 |
-
|
78 |
-
#: admin/assets/src/components/ScreenOptions.js:98
|
79 |
-
msgid "Shipping class"
|
80 |
msgstr ""
|
81 |
|
82 |
-
#: admin/
|
83 |
-
|
84 |
-
#: admin/assets/src/components/Products.js:102
|
85 |
-
#: admin/assets/src/components/ScreenOptions.js:43
|
86 |
-
msgid "Thumbnail"
|
87 |
msgstr ""
|
88 |
|
89 |
-
#: admin/
|
90 |
-
|
91 |
-
msgid "Name"
|
92 |
msgstr ""
|
93 |
|
94 |
-
#: admin/
|
95 |
-
|
96 |
-
#: admin/views/log.php:32
|
97 |
-
#: admin/assets/src/components/Products.js:97
|
98 |
-
msgid "Product type"
|
99 |
msgstr ""
|
100 |
|
101 |
-
#: admin/
|
102 |
-
|
103 |
-
#: admin/views/log.php:33
|
104 |
-
msgid "Parent ID"
|
105 |
msgstr ""
|
106 |
|
107 |
-
#: admin/
|
108 |
-
|
109 |
-
#: admin/assets/src/components/Products.js:130
|
110 |
-
#: admin/assets/src/components/ScreenOptions.js:53
|
111 |
-
msgid "Price"
|
112 |
msgstr ""
|
113 |
|
114 |
-
#: admin/
|
115 |
-
|
116 |
-
#: admin/assets/src/components/ScreenOptions.js:58
|
117 |
-
msgid "Sale price"
|
118 |
msgstr ""
|
119 |
|
120 |
-
#: admin/
|
121 |
-
#: admin/views/
|
122 |
-
#: admin/assets/src/components/Products.js:
|
123 |
-
|
124 |
-
msgid "Weight"
|
125 |
msgstr ""
|
126 |
|
127 |
-
#: admin/
|
128 |
-
#: admin/
|
129 |
-
#: admin/
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
132 |
#: admin/assets/src/components/Products.js:139
|
133 |
#: admin/assets/src/components/ScreenOptions.js:68
|
134 |
msgid "Manage stock"
|
135 |
msgstr ""
|
136 |
|
137 |
-
#: admin/
|
138 |
-
#: admin/views/import-export.php:
|
139 |
-
#: admin/views/import-export.php:148
|
140 |
-
#: admin/views/components/filter.php:46
|
141 |
-
#: admin/views/components/filter.php:114
|
142 |
#: admin/assets/src/components/ProductFilter.js:112
|
143 |
#: admin/assets/src/components/Products.js:142
|
144 |
#: admin/assets/src/components/ScreenOptions.js:73
|
145 |
msgid "Stock status"
|
146 |
msgstr ""
|
147 |
|
148 |
-
#: admin/
|
149 |
-
#: admin/views/import-export.php:
|
150 |
-
#: admin/views/import-export.php:149
|
151 |
-
#: admin/views/components/filter.php:116
|
152 |
#: admin/assets/src/components/Products.js:145
|
153 |
#: admin/assets/src/components/ScreenOptions.js:78
|
154 |
msgid "Backorders"
|
155 |
msgstr ""
|
156 |
|
157 |
-
#: admin/
|
158 |
-
#: admin/views/import-export.php:128
|
159 |
-
#: admin/views/import-export.php:150
|
160 |
-
#: admin/views/log-history.php:38
|
161 |
-
#: admin/views/log.php:34
|
162 |
-
#: admin/views/components/filter.php:118
|
163 |
-
#: admin/assets/src/components/Products.js:148
|
164 |
-
#: admin/assets/src/components/ScreenOptions.js:83
|
165 |
-
msgid "Stock"
|
166 |
-
msgstr ""
|
167 |
-
|
168 |
-
#: admin/includes/wcm-class-table.php:373
|
169 |
-
#: admin/includes/wcm-class-table.php:418
|
170 |
-
#: admin/includes/wcm-class-table.php:450
|
171 |
-
#: admin/includes/wcm-class-table.php:735
|
172 |
-
msgid "Save"
|
173 |
-
msgstr ""
|
174 |
-
|
175 |
-
#: admin/includes/wcm-class-table.php:419
|
176 |
-
#: admin/includes/wcm-class-table.php:451
|
177 |
-
msgid "Close"
|
178 |
-
msgstr ""
|
179 |
-
|
180 |
-
#: admin/includes/wcm-class-table.php:466
|
181 |
-
msgid "Show variables"
|
182 |
-
msgstr ""
|
183 |
-
|
184 |
-
#: admin/includes/wcm-class-table.php:544
|
185 |
-
msgid "Same as parent"
|
186 |
-
msgstr ""
|
187 |
-
|
188 |
-
#: admin/includes/wcm-class-table.php:546
|
189 |
-
#: admin/class-stock-manager-admin.php:156
|
190 |
-
msgid "No shipping class"
|
191 |
-
msgstr ""
|
192 |
-
|
193 |
-
#: admin/includes/wcm-class-table.php:628
|
194 |
-
#: admin/includes/wcm-class-table.php:661
|
195 |
-
#: admin/class-stock-manager-admin.php:169
|
196 |
-
msgid "Yes"
|
197 |
-
msgstr ""
|
198 |
-
|
199 |
-
#: admin/includes/wcm-class-table.php:629
|
200 |
-
#: admin/includes/wcm-class-table.php:659
|
201 |
-
#: admin/class-stock-manager-admin.php:167
|
202 |
-
msgid "No"
|
203 |
-
msgstr ""
|
204 |
-
|
205 |
-
#: admin/includes/wcm-class-table.php:643
|
206 |
-
#: admin/views/components/filter.php:47
|
207 |
-
msgid "In stock"
|
208 |
-
msgstr ""
|
209 |
-
|
210 |
-
#: admin/includes/wcm-class-table.php:644
|
211 |
-
#: admin/views/components/filter.php:48
|
212 |
-
msgid "Out of stock"
|
213 |
-
msgstr ""
|
214 |
-
|
215 |
-
#: admin/includes/wcm-class-table.php:645
|
216 |
-
msgid "On backorder"
|
217 |
-
msgstr ""
|
218 |
-
|
219 |
-
#: admin/includes/wcm-class-table.php:660
|
220 |
-
#: admin/class-stock-manager-admin.php:168
|
221 |
-
msgid "Notify"
|
222 |
-
msgstr ""
|
223 |
-
|
224 |
-
#: admin/views/import-export.php:113
|
225 |
-
msgid "Import"
|
226 |
-
msgstr ""
|
227 |
-
|
228 |
-
#: admin/views/import-export.php:116
|
229 |
-
msgid "You can upload csv file, with your stock data. "
|
230 |
-
msgstr ""
|
231 |
-
|
232 |
-
#: admin/views/import-export.php:117
|
233 |
-
msgid "CSV file must be in this format, or you can export file with exist data and edit them. "
|
234 |
-
msgstr ""
|
235 |
-
|
236 |
-
#: admin/views/import-export.php:118
|
237 |
-
msgid "If you have a lot of products and export/import not working, increase memory limit.. "
|
238 |
-
msgstr ""
|
239 |
-
|
240 |
-
#: admin/views/import-export.php:119
|
241 |
-
msgid "File format"
|
242 |
-
msgstr ""
|
243 |
-
|
244 |
-
#: admin/views/import-export.php:124
|
245 |
-
#: admin/assets/src/components/Products.js:115
|
246 |
-
#: admin/assets/src/components/ScreenOptions.js:48
|
247 |
-
msgid "Product name"
|
248 |
-
msgstr ""
|
249 |
-
|
250 |
-
#: admin/views/import-export.php:133
|
251 |
msgid "123"
|
252 |
msgstr ""
|
253 |
|
254 |
-
#: admin/views/import-export.php:
|
255 |
msgid "abc111"
|
256 |
msgstr ""
|
257 |
|
258 |
-
#: admin/views/import-export.php:
|
259 |
msgid "T-shirt"
|
260 |
msgstr ""
|
261 |
|
262 |
-
#: admin/views/import-export.php:
|
263 |
-
#: admin/views/import-export.php:
|
264 |
msgid "yes"
|
265 |
msgstr ""
|
266 |
|
267 |
-
#: admin/views/import-export.php:
|
268 |
msgid "instock"
|
269 |
msgstr ""
|
270 |
|
271 |
-
#: admin/views/import-export.php:
|
272 |
msgid "10"
|
273 |
msgstr ""
|
274 |
|
275 |
-
#: admin/views/import-export.php:
|
276 |
msgid "simple"
|
277 |
msgstr ""
|
278 |
|
279 |
-
#: admin/views/import-export.php:
|
280 |
msgid "product id, required. Neccessary for import and export."
|
281 |
msgstr ""
|
282 |
|
283 |
-
#: admin/views/import-export.php:
|
284 |
msgid "product unique identificator."
|
285 |
msgstr ""
|
286 |
|
287 |
-
#: admin/views/import-export.php:
|
288 |
-
#: admin/views/import-export.php:
|
289 |
msgid "values: \"yes\", \"notify\", \"no\". If is empty \"no\" will be save."
|
290 |
msgstr ""
|
291 |
|
292 |
-
#: admin/views/import-export.php:
|
293 |
msgid "values: \"instock\", \"outofstock\". If is empty \"outofstock\" will be save."
|
294 |
msgstr ""
|
295 |
|
296 |
-
#: admin/views/import-export.php:
|
297 |
msgid "quantity value. If is empty, 0 will be save."
|
298 |
msgstr ""
|
299 |
|
300 |
-
#: admin/views/import-export.php:
|
301 |
msgid "Upload csv file"
|
302 |
msgstr ""
|
303 |
|
304 |
-
#: admin/views/import-export.php:
|
305 |
msgid "Upload"
|
306 |
msgstr ""
|
307 |
|
308 |
-
|
309 |
-
|
|
|
310 |
msgstr ""
|
311 |
|
312 |
-
|
313 |
-
|
|
|
314 |
msgstr ""
|
315 |
|
316 |
-
#: admin/views/import-export.php:
|
317 |
msgid "Sorry, there was an error uploading your file."
|
318 |
msgstr ""
|
319 |
|
320 |
-
#: admin/views/import-export.php:
|
321 |
msgid "Error: You have not uploaded a CSV file."
|
322 |
msgstr ""
|
323 |
|
324 |
-
#: admin/views/import-export.php:
|
325 |
msgid "Export"
|
326 |
msgstr ""
|
327 |
|
328 |
-
#: admin/views/import-export.php:
|
329 |
msgid "You can download csv file, with your stock data. "
|
330 |
msgstr ""
|
331 |
|
332 |
-
#: admin/views/import-export.php:
|
333 |
msgid "Create export file"
|
334 |
msgstr ""
|
335 |
|
336 |
-
#: admin/
|
337 |
-
msgid "
|
338 |
-
msgstr ""
|
339 |
-
|
340 |
-
#: admin/views/log-history.php:58
|
341 |
-
msgid "No result"
|
342 |
-
msgstr ""
|
343 |
-
|
344 |
-
#: admin/views/log.php:20
|
345 |
-
msgid "Stock manager"
|
346 |
-
msgstr ""
|
347 |
-
|
348 |
-
#: admin/views/log.php:56
|
349 |
-
#: admin/views/log.php:87
|
350 |
-
msgid "History"
|
351 |
-
msgstr ""
|
352 |
-
|
353 |
-
#: admin/views/setting.php:22
|
354 |
-
#: admin/views/stock-monitor.php:32
|
355 |
-
msgid "Stock manager setting"
|
356 |
-
msgstr ""
|
357 |
-
|
358 |
-
#: admin/views/setting.php:29
|
359 |
-
msgid "Active old styles"
|
360 |
-
msgstr ""
|
361 |
-
|
362 |
-
#: admin/views/stock-monitor.php:39
|
363 |
-
msgid "Products limit"
|
364 |
-
msgstr ""
|
365 |
-
|
366 |
-
#: admin/views/stock-monitor.php:43
|
367 |
-
msgid "Allow stock for variable products"
|
368 |
-
msgstr ""
|
369 |
-
|
370 |
-
#: admin/views/stock-monitor.php:47
|
371 |
-
msgid "Qty input step"
|
372 |
-
msgstr ""
|
373 |
-
|
374 |
-
#: admin/views/components/filter.php:3
|
375 |
-
msgid "Filter"
|
376 |
-
msgstr ""
|
377 |
-
|
378 |
-
#: admin/views/components/filter.php:4
|
379 |
-
#: admin/views/components/filter.php:63
|
380 |
-
msgid "Search by sku"
|
381 |
-
msgstr ""
|
382 |
-
|
383 |
-
#: admin/views/components/filter.php:5
|
384 |
-
#: admin/views/components/filter.php:73
|
385 |
-
msgid "Search by product name"
|
386 |
-
msgstr ""
|
387 |
-
|
388 |
-
#: admin/views/components/filter.php:6
|
389 |
-
msgid "Display setting"
|
390 |
-
msgstr ""
|
391 |
-
|
392 |
-
#: admin/views/components/filter.php:15
|
393 |
-
msgid "Order by"
|
394 |
-
msgstr ""
|
395 |
-
|
396 |
-
#: admin/views/components/filter.php:16
|
397 |
-
msgid "Product name ASC"
|
398 |
-
msgstr ""
|
399 |
-
|
400 |
-
#: admin/views/components/filter.php:17
|
401 |
-
msgid "Product name DESC"
|
402 |
-
msgstr ""
|
403 |
-
|
404 |
-
#: admin/views/components/filter.php:18
|
405 |
-
msgid "SKU ASC"
|
406 |
-
msgstr ""
|
407 |
-
|
408 |
-
#: admin/views/components/filter.php:19
|
409 |
-
msgid "SKU DESC"
|
410 |
-
msgstr ""
|
411 |
-
|
412 |
-
#: admin/views/components/filter.php:23
|
413 |
-
msgid "Simple products"
|
414 |
msgstr ""
|
415 |
|
416 |
-
#: admin/
|
417 |
-
msgid "
|
418 |
msgstr ""
|
419 |
|
420 |
-
#: admin/
|
421 |
-
msgid "
|
422 |
msgstr ""
|
423 |
|
424 |
-
#: admin/
|
425 |
-
|
|
|
426 |
msgstr ""
|
427 |
|
428 |
-
#: admin/
|
429 |
-
msgid "
|
430 |
msgstr ""
|
431 |
|
432 |
-
#: admin/
|
433 |
-
msgid "
|
434 |
msgstr ""
|
435 |
|
436 |
-
#: admin/
|
437 |
-
msgid "
|
438 |
msgstr ""
|
439 |
|
440 |
-
#: admin/
|
441 |
-
|
|
|
442 |
msgstr ""
|
443 |
|
444 |
-
#: admin/
|
445 |
-
|
|
|
446 |
msgstr ""
|
447 |
|
448 |
-
#: admin/
|
449 |
-
|
|
|
450 |
msgstr ""
|
451 |
|
452 |
-
#: admin/class-stock-manager-admin.php:
|
453 |
-
msgid "
|
454 |
msgstr ""
|
455 |
|
456 |
-
#: admin/class-stock-manager-admin.php:
|
457 |
-
msgid "
|
458 |
msgstr ""
|
459 |
|
460 |
-
#: admin/class-stock-manager-admin.php:
|
461 |
-
|
462 |
-
msgid "
|
463 |
msgstr ""
|
464 |
|
465 |
#. translators: %1$s & %2$s: Opening & closing strong tag. %3$s: link to Stock Manager for WooCommerce on WordPress.org
|
466 |
-
#: admin/class-stock-manager-admin.php:
|
467 |
-
msgid "If you are liking %1$
|
468 |
msgstr ""
|
469 |
|
470 |
-
#: woocommerce-stock-manager.php:
|
471 |
msgid "Alert!"
|
472 |
msgstr ""
|
473 |
|
474 |
-
#: woocommerce-stock-manager.php:
|
475 |
msgid "Stock Manager for WooCommerce needs following versions of WordPress and WooCommerce:"
|
476 |
msgstr ""
|
477 |
|
478 |
-
#: woocommerce-stock-manager.php:
|
479 |
msgid "Please update WordPress and WooCommerce to the above versions before updating Stock Manager for WooCommerce."
|
480 |
msgstr ""
|
481 |
|
482 |
-
#: woocommerce-stock-manager.php:
|
483 |
msgid "All done! Close."
|
484 |
msgstr ""
|
485 |
|
@@ -505,6 +330,41 @@ msgstr ""
|
|
505 |
msgid "Loading failed"
|
506 |
msgstr ""
|
507 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
508 |
#: admin/assets/src/components/Products.js:160
|
509 |
msgid "Loading more results..."
|
510 |
msgstr ""
|
2 |
# This file is distributed under the same license as the Stock Manager for WooCommerce plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Stock Manager for WooCommerce 2.8.0\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woocommerce-stock-manager\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"POT-Creation-Date: 2021-09-17T10:36:10+05:30\n"
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
"X-Generator: WP-CLI 2.1.0\n"
|
15 |
"X-Domain: woocommerce-stock-manager\n"
|
34 |
msgid "https://www.storeapps.org/"
|
35 |
msgstr ""
|
36 |
|
37 |
+
#: admin/views/log-history.php:48
|
38 |
+
msgid "Date"
|
39 |
+
msgstr ""
|
40 |
+
|
41 |
+
#: admin/views/log-history.php:49
|
42 |
+
#: admin/views/log.php:33
|
43 |
+
#: admin/views/import-export.php:136
|
44 |
+
#: admin/views/import-export.php:158
|
45 |
+
#: admin/assets/src/components/Products.js:148
|
46 |
+
#: admin/assets/src/components/ScreenOptions.js:83
|
47 |
+
msgid "Stock"
|
48 |
+
msgstr ""
|
49 |
+
|
50 |
+
#: admin/views/log-history.php:69
|
51 |
+
msgid "No result"
|
52 |
+
msgstr ""
|
53 |
+
|
54 |
+
#: admin/views/log.php:28
|
55 |
+
msgid "Product ID"
|
56 |
+
msgstr ""
|
57 |
+
|
58 |
#: admin/views/log.php:29
|
59 |
+
#: admin/views/import-export.php:131
|
60 |
+
#: admin/views/import-export.php:154
|
61 |
#: admin/assets/src/components/ProductFilter.js:64
|
62 |
#: admin/assets/src/components/Products.js:99
|
63 |
#: admin/assets/src/components/ScreenOptions.js:38
|
64 |
msgid "SKU"
|
65 |
msgstr ""
|
66 |
|
|
|
|
|
|
|
|
|
67 |
#: admin/views/log.php:30
|
68 |
+
msgid "Name"
|
|
|
69 |
msgstr ""
|
70 |
|
71 |
+
#: admin/views/log.php:31
|
72 |
+
#: admin/views/import-export.php:137
|
73 |
+
#: admin/assets/src/components/Products.js:97
|
74 |
+
msgid "Product type"
|
|
|
75 |
msgstr ""
|
76 |
|
77 |
+
#: admin/views/log.php:32
|
78 |
+
#: admin/views/import-export.php:138
|
79 |
+
msgid "Parent ID"
|
|
|
|
|
80 |
msgstr ""
|
81 |
|
82 |
+
#: admin/views/log.php:60
|
83 |
+
#: admin/views/log.php:94
|
84 |
+
msgid "History"
|
|
|
|
|
85 |
msgstr ""
|
86 |
|
87 |
+
#: admin/views/setting.php:34
|
88 |
+
msgid "Active old styles"
|
|
|
|
|
|
|
89 |
msgstr ""
|
90 |
|
91 |
+
#: admin/views/import-export.php:121
|
92 |
+
msgid "Import"
|
|
|
93 |
msgstr ""
|
94 |
|
95 |
+
#: admin/views/import-export.php:124
|
96 |
+
msgid "You can upload csv file, with your stock data. "
|
|
|
|
|
|
|
97 |
msgstr ""
|
98 |
|
99 |
+
#: admin/views/import-export.php:125
|
100 |
+
msgid "CSV file must be in this format, or you can export file with exist data and edit them. "
|
|
|
|
|
101 |
msgstr ""
|
102 |
|
103 |
+
#: admin/views/import-export.php:126
|
104 |
+
msgid "If you have a lot of products and export/import not working, increase memory limit.. "
|
|
|
|
|
|
|
105 |
msgstr ""
|
106 |
|
107 |
+
#: admin/views/import-export.php:127
|
108 |
+
msgid "File format"
|
|
|
|
|
109 |
msgstr ""
|
110 |
|
111 |
+
#: admin/views/import-export.php:130
|
112 |
+
#: admin/views/import-export.php:153
|
113 |
+
#: admin/assets/src/components/Products.js:93
|
114 |
+
msgid "ID"
|
|
|
115 |
msgstr ""
|
116 |
|
117 |
+
#: admin/views/import-export.php:132
|
118 |
+
#: admin/assets/src/components/Products.js:115
|
119 |
+
#: admin/assets/src/components/ScreenOptions.js:48
|
120 |
+
msgid "Product name"
|
121 |
+
msgstr ""
|
122 |
+
|
123 |
+
#: admin/views/import-export.php:133
|
124 |
+
#: admin/views/import-export.php:155
|
125 |
#: admin/assets/src/components/Products.js:139
|
126 |
#: admin/assets/src/components/ScreenOptions.js:68
|
127 |
msgid "Manage stock"
|
128 |
msgstr ""
|
129 |
|
130 |
+
#: admin/views/import-export.php:134
|
131 |
+
#: admin/views/import-export.php:156
|
|
|
|
|
|
|
132 |
#: admin/assets/src/components/ProductFilter.js:112
|
133 |
#: admin/assets/src/components/Products.js:142
|
134 |
#: admin/assets/src/components/ScreenOptions.js:73
|
135 |
msgid "Stock status"
|
136 |
msgstr ""
|
137 |
|
138 |
+
#: admin/views/import-export.php:135
|
139 |
+
#: admin/views/import-export.php:157
|
|
|
|
|
140 |
#: admin/assets/src/components/Products.js:145
|
141 |
#: admin/assets/src/components/ScreenOptions.js:78
|
142 |
msgid "Backorders"
|
143 |
msgstr ""
|
144 |
|
145 |
+
#: admin/views/import-export.php:141
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
msgid "123"
|
147 |
msgstr ""
|
148 |
|
149 |
+
#: admin/views/import-export.php:142
|
150 |
msgid "abc111"
|
151 |
msgstr ""
|
152 |
|
153 |
+
#: admin/views/import-export.php:143
|
154 |
msgid "T-shirt"
|
155 |
msgstr ""
|
156 |
|
157 |
+
#: admin/views/import-export.php:144
|
158 |
+
#: admin/views/import-export.php:146
|
159 |
msgid "yes"
|
160 |
msgstr ""
|
161 |
|
162 |
+
#: admin/views/import-export.php:145
|
163 |
msgid "instock"
|
164 |
msgstr ""
|
165 |
|
166 |
+
#: admin/views/import-export.php:147
|
167 |
msgid "10"
|
168 |
msgstr ""
|
169 |
|
170 |
+
#: admin/views/import-export.php:148
|
171 |
msgid "simple"
|
172 |
msgstr ""
|
173 |
|
174 |
+
#: admin/views/import-export.php:153
|
175 |
msgid "product id, required. Neccessary for import and export."
|
176 |
msgstr ""
|
177 |
|
178 |
+
#: admin/views/import-export.php:154
|
179 |
msgid "product unique identificator."
|
180 |
msgstr ""
|
181 |
|
182 |
+
#: admin/views/import-export.php:155
|
183 |
+
#: admin/views/import-export.php:157
|
184 |
msgid "values: \"yes\", \"notify\", \"no\". If is empty \"no\" will be save."
|
185 |
msgstr ""
|
186 |
|
187 |
+
#: admin/views/import-export.php:156
|
188 |
msgid "values: \"instock\", \"outofstock\". If is empty \"outofstock\" will be save."
|
189 |
msgstr ""
|
190 |
|
191 |
+
#: admin/views/import-export.php:158
|
192 |
msgid "quantity value. If is empty, 0 will be save."
|
193 |
msgstr ""
|
194 |
|
195 |
+
#: admin/views/import-export.php:163
|
196 |
msgid "Upload csv file"
|
197 |
msgstr ""
|
198 |
|
199 |
+
#: admin/views/import-export.php:172
|
200 |
msgid "Upload"
|
201 |
msgstr ""
|
202 |
|
203 |
+
#. translators: 1: Uploaded file name
|
204 |
+
#: admin/views/import-export.php:195
|
205 |
+
msgid "The file %1$s has been uploaded"
|
206 |
msgstr ""
|
207 |
|
208 |
+
#. translators: 1: P tag opening 2: Updated Product ID 3. Closing p tag
|
209 |
+
#: admin/views/import-export.php:225
|
210 |
+
msgid "%1$s Product with ID %2$s was updated. %3$s"
|
211 |
msgstr ""
|
212 |
|
213 |
+
#: admin/views/import-export.php:234
|
214 |
msgid "Sorry, there was an error uploading your file."
|
215 |
msgstr ""
|
216 |
|
217 |
+
#: admin/views/import-export.php:237
|
218 |
msgid "Error: You have not uploaded a CSV file."
|
219 |
msgstr ""
|
220 |
|
221 |
+
#: admin/views/import-export.php:251
|
222 |
msgid "Export"
|
223 |
msgstr ""
|
224 |
|
225 |
+
#: admin/views/import-export.php:254
|
226 |
msgid "You can download csv file, with your stock data. "
|
227 |
msgstr ""
|
228 |
|
229 |
+
#: admin/views/import-export.php:255
|
230 |
msgid "Create export file"
|
231 |
msgstr ""
|
232 |
|
233 |
+
#: admin/class-stock-manager-admin.php:153
|
234 |
+
msgid "No shipping class"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
msgstr ""
|
236 |
|
237 |
+
#: admin/class-stock-manager-admin.php:170
|
238 |
+
msgid "Taxable"
|
239 |
msgstr ""
|
240 |
|
241 |
+
#: admin/class-stock-manager-admin.php:171
|
242 |
+
msgid "Shipping only"
|
243 |
msgstr ""
|
244 |
|
245 |
+
#: admin/class-stock-manager-admin.php:172
|
246 |
+
msgctxt "Tax status"
|
247 |
+
msgid "None"
|
248 |
msgstr ""
|
249 |
|
250 |
+
#: admin/class-stock-manager-admin.php:175
|
251 |
+
msgid "No"
|
252 |
msgstr ""
|
253 |
|
254 |
+
#: admin/class-stock-manager-admin.php:176
|
255 |
+
msgid "Notify"
|
256 |
msgstr ""
|
257 |
|
258 |
+
#: admin/class-stock-manager-admin.php:177
|
259 |
+
msgid "Yes"
|
260 |
msgstr ""
|
261 |
|
262 |
+
#: admin/class-stock-manager-admin.php:237
|
263 |
+
#: admin/class-stock-manager-admin.php:238
|
264 |
+
msgid "Stock Manager"
|
265 |
msgstr ""
|
266 |
|
267 |
+
#: admin/class-stock-manager-admin.php:261
|
268 |
+
#: admin/class-stock-manager-admin.php:262
|
269 |
+
msgid "Import/Export"
|
270 |
msgstr ""
|
271 |
|
272 |
+
#: admin/class-stock-manager-admin.php:269
|
273 |
+
#: admin/class-stock-manager-admin.php:270
|
274 |
+
msgid "Stock log"
|
275 |
msgstr ""
|
276 |
|
277 |
+
#: admin/class-stock-manager-admin.php:277
|
278 |
+
msgid "Stock Manager Setting"
|
279 |
msgstr ""
|
280 |
|
281 |
+
#: admin/class-stock-manager-admin.php:278
|
282 |
+
msgid "Setting"
|
283 |
msgstr ""
|
284 |
|
285 |
+
#: admin/class-stock-manager-admin.php:285
|
286 |
+
#: admin/class-stock-manager-admin.php:286
|
287 |
+
msgid "StoreApps Plugins"
|
288 |
msgstr ""
|
289 |
|
290 |
#. translators: %1$s & %2$s: Opening & closing strong tag. %3$s: link to Stock Manager for WooCommerce on WordPress.org
|
291 |
+
#: admin/class-stock-manager-admin.php:473
|
292 |
+
msgid "If you are liking %1$sStock Manager for WooCommerce%2$s, please rate us %3$s. A huge thanks from StoreApps in advance!"
|
293 |
msgstr ""
|
294 |
|
295 |
+
#: woocommerce-stock-manager.php:76
|
296 |
msgid "Alert!"
|
297 |
msgstr ""
|
298 |
|
299 |
+
#: woocommerce-stock-manager.php:76
|
300 |
msgid "Stock Manager for WooCommerce needs following versions of WordPress and WooCommerce:"
|
301 |
msgstr ""
|
302 |
|
303 |
+
#: woocommerce-stock-manager.php:89
|
304 |
msgid "Please update WordPress and WooCommerce to the above versions before updating Stock Manager for WooCommerce."
|
305 |
msgstr ""
|
306 |
|
307 |
+
#: woocommerce-stock-manager.php:272
|
308 |
msgid "All done! Close."
|
309 |
msgstr ""
|
310 |
|
330 |
msgid "Loading failed"
|
331 |
msgstr ""
|
332 |
|
333 |
+
#: admin/assets/src/components/Products.js:102
|
334 |
+
#: admin/assets/src/components/ScreenOptions.js:43
|
335 |
+
msgid "Thumbnail"
|
336 |
+
msgstr ""
|
337 |
+
|
338 |
+
#: admin/assets/src/components/Products.js:121
|
339 |
+
#: admin/assets/src/components/ScreenOptions.js:88
|
340 |
+
msgid "Tax status"
|
341 |
+
msgstr ""
|
342 |
+
|
343 |
+
#: admin/assets/src/components/Products.js:124
|
344 |
+
#: admin/assets/src/components/ScreenOptions.js:93
|
345 |
+
msgid "Tax class"
|
346 |
+
msgstr ""
|
347 |
+
|
348 |
+
#: admin/assets/src/components/Products.js:127
|
349 |
+
#: admin/assets/src/components/ScreenOptions.js:98
|
350 |
+
msgid "Shipping class"
|
351 |
+
msgstr ""
|
352 |
+
|
353 |
+
#: admin/assets/src/components/Products.js:130
|
354 |
+
#: admin/assets/src/components/ScreenOptions.js:53
|
355 |
+
msgid "Price"
|
356 |
+
msgstr ""
|
357 |
+
|
358 |
+
#: admin/assets/src/components/Products.js:133
|
359 |
+
#: admin/assets/src/components/ScreenOptions.js:58
|
360 |
+
msgid "Sale price"
|
361 |
+
msgstr ""
|
362 |
+
|
363 |
+
#: admin/assets/src/components/Products.js:136
|
364 |
+
#: admin/assets/src/components/ScreenOptions.js:63
|
365 |
+
msgid "Weight"
|
366 |
+
msgstr ""
|
367 |
+
|
368 |
#: admin/assets/src/components/Products.js:160
|
369 |
msgid "Loading more results..."
|
370 |
msgstr ""
|
public/class-stock-manager.php
CHANGED
@@ -3,18 +3,20 @@
|
|
3 |
* Stock Manager
|
4 |
*
|
5 |
* @package woocommerce-stock-manager/public/
|
6 |
-
* @version 2.
|
7 |
*/
|
8 |
|
9 |
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
exit;
|
11 |
}
|
12 |
|
|
|
|
|
|
|
13 |
class Stock_Manager {
|
14 |
|
15 |
/**
|
16 |
* Plugin slug
|
17 |
-
* @since 1.0.0
|
18 |
*
|
19 |
* @var string
|
20 |
*/
|
@@ -23,37 +25,30 @@ class Stock_Manager {
|
|
23 |
/**
|
24 |
* Instance of this class.
|
25 |
*
|
26 |
-
* @since 1.0.0
|
27 |
-
*
|
28 |
* @var object
|
29 |
*/
|
30 |
protected static $instance = null;
|
31 |
|
32 |
/**
|
33 |
-
* Initialize the plugin by setting
|
34 |
-
* and styles.
|
35 |
-
*
|
36 |
-
* @since 1.0.0
|
37 |
*/
|
38 |
private function __construct() {
|
39 |
|
40 |
-
// Activate plugin when new blog is added
|
41 |
add_action( 'wpmu_new_blog', array( $this, 'activate_new_site' ) );
|
42 |
|
43 |
add_action( 'init', array( $this, 'output_buffer' ) );
|
44 |
-
|
45 |
add_action( 'init', array( $this, 'create_table' ) );
|
46 |
|
47 |
add_action( 'woocommerce_product_set_stock', array( $this, 'save_stock' ) );
|
48 |
add_action( 'woocommerce_variation_set_stock', array( $this, 'save_stock' ) );
|
49 |
-
|
50 |
-
}
|
51 |
|
52 |
/**
|
53 |
* Return the plugin slug.
|
54 |
*
|
55 |
-
* @since 1.0.0
|
56 |
-
*
|
57 |
* @return Plugin slug variable.
|
58 |
*/
|
59 |
public function get_plugin_slug() {
|
@@ -63,14 +58,12 @@ class Stock_Manager {
|
|
63 |
/**
|
64 |
* Return an instance of this class.
|
65 |
*
|
66 |
-
* @since 1.0.0
|
67 |
-
*
|
68 |
* @return object A single instance of this class.
|
69 |
*/
|
70 |
public static function get_instance() {
|
71 |
// If the single instance hasn't been set, set it now.
|
72 |
-
if (
|
73 |
-
self::$instance = new self;
|
74 |
}
|
75 |
|
76 |
return self::$instance;
|
@@ -79,20 +72,18 @@ class Stock_Manager {
|
|
79 |
/**
|
80 |
* Fired when the plugin is activated.
|
81 |
*
|
82 |
-
* @
|
83 |
-
*
|
84 |
-
*
|
85 |
-
*
|
86 |
-
* WPMU is disabled or plugin is
|
87 |
-
* activated on an individual blog.
|
88 |
*/
|
89 |
public static function activate( $network_wide ) {
|
90 |
|
91 |
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
92 |
|
93 |
-
if ( $network_wide
|
94 |
|
95 |
-
// Get all blog ids
|
96 |
$blog_ids = self::get_blog_ids();
|
97 |
|
98 |
foreach ( $blog_ids as $blog_id ) {
|
@@ -106,7 +97,6 @@ class Stock_Manager {
|
|
106 |
} else {
|
107 |
self::single_activate();
|
108 |
}
|
109 |
-
|
110 |
} else {
|
111 |
self::single_activate();
|
112 |
}
|
@@ -116,12 +106,10 @@ class Stock_Manager {
|
|
116 |
/**
|
117 |
* Fired when the plugin is deactivated.
|
118 |
*
|
119 |
-
* @
|
120 |
-
*
|
121 |
-
*
|
122 |
-
*
|
123 |
-
* WPMU is disabled or plugin is
|
124 |
-
* deactivated on an individual blog.
|
125 |
*/
|
126 |
public static function deactivate( $network_wide ) {
|
127 |
|
@@ -129,7 +117,7 @@ class Stock_Manager {
|
|
129 |
|
130 |
if ( $network_wide ) {
|
131 |
|
132 |
-
// Get all blog ids
|
133 |
$blog_ids = self::get_blog_ids();
|
134 |
|
135 |
foreach ( $blog_ids as $blog_id ) {
|
@@ -144,7 +132,6 @@ class Stock_Manager {
|
|
144 |
} else {
|
145 |
self::single_deactivate();
|
146 |
}
|
147 |
-
|
148 |
} else {
|
149 |
self::single_deactivate();
|
150 |
}
|
@@ -154,9 +141,7 @@ class Stock_Manager {
|
|
154 |
/**
|
155 |
* Fired when a new site is activated with a WPMU environment.
|
156 |
*
|
157 |
-
* @
|
158 |
-
*
|
159 |
-
* @param int $blog_id ID of the new blog.
|
160 |
*/
|
161 |
public function activate_new_site( $blog_id ) {
|
162 |
|
@@ -176,27 +161,30 @@ class Stock_Manager {
|
|
176 |
* - not spam
|
177 |
* - not deleted
|
178 |
*
|
179 |
-
* @since 1.0.0
|
180 |
-
*
|
181 |
* @return array|false The blog ids, false if no matches.
|
182 |
*/
|
183 |
private static function get_blog_ids() {
|
184 |
|
185 |
global $wpdb;
|
186 |
|
187 |
-
// get an array of blog ids
|
188 |
-
$
|
189 |
-
|
190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
|
192 |
-
return $
|
193 |
|
194 |
}
|
195 |
|
196 |
/**
|
197 |
* Fired for each blog when the plugin is activated.
|
198 |
-
*
|
199 |
-
* @since 1.0.0
|
200 |
*/
|
201 |
private static function single_activate() {
|
202 |
|
@@ -204,8 +192,6 @@ class Stock_Manager {
|
|
204 |
|
205 |
/**
|
206 |
* Fired for each blog when the plugin is deactivated.
|
207 |
-
*
|
208 |
-
* @since 1.0.0
|
209 |
*/
|
210 |
private static function single_deactivate() {
|
211 |
|
@@ -213,36 +199,33 @@ class Stock_Manager {
|
|
213 |
|
214 |
/**
|
215 |
* Headers allready sent fix
|
216 |
-
|
217 |
-
|
218 |
-
public function output_buffer() {
|
219 |
ob_start();
|
220 |
}
|
221 |
-
|
222 |
/**
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
*/
|
227 |
-
public function create_table() {
|
228 |
|
229 |
global $wpdb;
|
230 |
-
|
231 |
$wpdb->hide_errors();
|
232 |
-
|
233 |
$collate = '';
|
234 |
-
|
235 |
if ( $wpdb->has_cap( 'collation' ) ) {
|
236 |
-
if ( ! empty($wpdb->charset ) ) {
|
237 |
$collate .= "DEFAULT CHARACTER SET $wpdb->charset";
|
238 |
}
|
239 |
-
if ( ! empty($wpdb->collate ) ) {
|
240 |
$collate .= " COLLATE $wpdb->collate";
|
241 |
}
|
242 |
}
|
243 |
-
|
244 |
-
require_once
|
245 |
-
|
246 |
$table = "
|
247 |
CREATE TABLE {$wpdb->prefix}stock_log (
|
248 |
ID bigint(255) NOT NULL AUTO_INCREMENT,
|
@@ -257,22 +240,31 @@ class Stock_Manager {
|
|
257 |
}
|
258 |
|
259 |
/**
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
|
|
|
|
|
|
|
|
265 |
|
266 |
global $wpdb;
|
267 |
|
268 |
$data = array();
|
269 |
-
$data['date_created'] =
|
|
|
270 |
$data['qty'] = $product->get_stock_quantity();
|
271 |
$data['qty'] = ( empty( $data['qty'] ) ) ? 0 : intval( $data['qty'] );
|
272 |
-
|
273 |
-
|
274 |
-
|
|
|
|
|
|
|
|
|
275 |
|
276 |
}
|
277 |
|
278 |
-
}//
|
3 |
* Stock Manager
|
4 |
*
|
5 |
* @package woocommerce-stock-manager/public/
|
6 |
+
* @version 2.8.0
|
7 |
*/
|
8 |
|
9 |
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
exit;
|
11 |
}
|
12 |
|
13 |
+
/**
|
14 |
+
* Class for Stock Manager.
|
15 |
+
*/
|
16 |
class Stock_Manager {
|
17 |
|
18 |
/**
|
19 |
* Plugin slug
|
|
|
20 |
*
|
21 |
* @var string
|
22 |
*/
|
25 |
/**
|
26 |
* Instance of this class.
|
27 |
*
|
|
|
|
|
28 |
* @var object
|
29 |
*/
|
30 |
protected static $instance = null;
|
31 |
|
32 |
/**
|
33 |
+
* Initialize the plugin by setting activation, table, stock updates and loading public scripts and styles.
|
|
|
|
|
|
|
34 |
*/
|
35 |
private function __construct() {
|
36 |
|
37 |
+
// Activate plugin when new blog is added.
|
38 |
add_action( 'wpmu_new_blog', array( $this, 'activate_new_site' ) );
|
39 |
|
40 |
add_action( 'init', array( $this, 'output_buffer' ) );
|
41 |
+
|
42 |
add_action( 'init', array( $this, 'create_table' ) );
|
43 |
|
44 |
add_action( 'woocommerce_product_set_stock', array( $this, 'save_stock' ) );
|
45 |
add_action( 'woocommerce_variation_set_stock', array( $this, 'save_stock' ) );
|
46 |
+
|
47 |
+
}
|
48 |
|
49 |
/**
|
50 |
* Return the plugin slug.
|
51 |
*
|
|
|
|
|
52 |
* @return Plugin slug variable.
|
53 |
*/
|
54 |
public function get_plugin_slug() {
|
58 |
/**
|
59 |
* Return an instance of this class.
|
60 |
*
|
|
|
|
|
61 |
* @return object A single instance of this class.
|
62 |
*/
|
63 |
public static function get_instance() {
|
64 |
// If the single instance hasn't been set, set it now.
|
65 |
+
if ( is_null( self::$instance ) ) {
|
66 |
+
self::$instance = new self();
|
67 |
}
|
68 |
|
69 |
return self::$instance;
|
72 |
/**
|
73 |
* Fired when the plugin is activated.
|
74 |
*
|
75 |
+
* @param boolean $network_wide True if WPMU superadmin uses
|
76 |
+
* "Network Activate" action, false if
|
77 |
+
* WPMU is disabled or plugin is
|
78 |
+
* activated on an individual blog.
|
|
|
|
|
79 |
*/
|
80 |
public static function activate( $network_wide ) {
|
81 |
|
82 |
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
83 |
|
84 |
+
if ( $network_wide ) {
|
85 |
|
86 |
+
// Get all blog ids.
|
87 |
$blog_ids = self::get_blog_ids();
|
88 |
|
89 |
foreach ( $blog_ids as $blog_id ) {
|
97 |
} else {
|
98 |
self::single_activate();
|
99 |
}
|
|
|
100 |
} else {
|
101 |
self::single_activate();
|
102 |
}
|
106 |
/**
|
107 |
* Fired when the plugin is deactivated.
|
108 |
*
|
109 |
+
* @param boolean $network_wide True if WPMU superadmin uses
|
110 |
+
* "Network Deactivate" action, false if
|
111 |
+
* WPMU is disabled or plugin is
|
112 |
+
* deactivated on an individual blog.
|
|
|
|
|
113 |
*/
|
114 |
public static function deactivate( $network_wide ) {
|
115 |
|
117 |
|
118 |
if ( $network_wide ) {
|
119 |
|
120 |
+
// Get all blog ids.
|
121 |
$blog_ids = self::get_blog_ids();
|
122 |
|
123 |
foreach ( $blog_ids as $blog_id ) {
|
132 |
} else {
|
133 |
self::single_deactivate();
|
134 |
}
|
|
|
135 |
} else {
|
136 |
self::single_deactivate();
|
137 |
}
|
141 |
/**
|
142 |
* Fired when a new site is activated with a WPMU environment.
|
143 |
*
|
144 |
+
* @param int $blog_id ID of the new blog.
|
|
|
|
|
145 |
*/
|
146 |
public function activate_new_site( $blog_id ) {
|
147 |
|
161 |
* - not spam
|
162 |
* - not deleted
|
163 |
*
|
|
|
|
|
164 |
* @return array|false The blog ids, false if no matches.
|
165 |
*/
|
166 |
private static function get_blog_ids() {
|
167 |
|
168 |
global $wpdb;
|
169 |
|
170 |
+
// get an array of blog ids.
|
171 |
+
$result = $wpdb->get_col( // phpcs:ignore
|
172 |
+
$wpdb->prepare( // phpcs:ignore
|
173 |
+
"SELECT blog_id
|
174 |
+
FROM $wpdb->blogs
|
175 |
+
WHERE archived = %d AND spam = %d AND deleted = %d",
|
176 |
+
0,
|
177 |
+
0,
|
178 |
+
0
|
179 |
+
)
|
180 |
+
);
|
181 |
|
182 |
+
return $result;
|
183 |
|
184 |
}
|
185 |
|
186 |
/**
|
187 |
* Fired for each blog when the plugin is activated.
|
|
|
|
|
188 |
*/
|
189 |
private static function single_activate() {
|
190 |
|
192 |
|
193 |
/**
|
194 |
* Fired for each blog when the plugin is deactivated.
|
|
|
|
|
195 |
*/
|
196 |
private static function single_deactivate() {
|
197 |
|
199 |
|
200 |
/**
|
201 |
* Headers allready sent fix
|
202 |
+
*/
|
203 |
+
public function output_buffer() {
|
|
|
204 |
ob_start();
|
205 |
}
|
206 |
+
|
207 |
/**
|
208 |
+
* Create table if not exists
|
209 |
+
*/
|
210 |
+
public function create_table() {
|
|
|
|
|
211 |
|
212 |
global $wpdb;
|
213 |
+
|
214 |
$wpdb->hide_errors();
|
215 |
+
|
216 |
$collate = '';
|
217 |
+
|
218 |
if ( $wpdb->has_cap( 'collation' ) ) {
|
219 |
+
if ( ! empty( $wpdb->charset ) ) {
|
220 |
$collate .= "DEFAULT CHARACTER SET $wpdb->charset";
|
221 |
}
|
222 |
+
if ( ! empty( $wpdb->collate ) ) {
|
223 |
$collate .= " COLLATE $wpdb->collate";
|
224 |
}
|
225 |
}
|
226 |
+
|
227 |
+
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
228 |
+
|
229 |
$table = "
|
230 |
CREATE TABLE {$wpdb->prefix}stock_log (
|
231 |
ID bigint(255) NOT NULL AUTO_INCREMENT,
|
240 |
}
|
241 |
|
242 |
/**
|
243 |
+
* Save stock change
|
244 |
+
*
|
245 |
+
* @param WC_Product $product Product Object.
|
246 |
+
*/
|
247 |
+
public function save_stock( $product ) {
|
248 |
+
|
249 |
+
if ( ! $product instanceof WC_Product ) {
|
250 |
+
return;
|
251 |
+
}
|
252 |
|
253 |
global $wpdb;
|
254 |
|
255 |
$data = array();
|
256 |
+
$data['date_created'] = gmdate( 'Y-m-d H:i:s', time() );
|
257 |
+
$data['product_id'] = $product->get_id();
|
258 |
$data['qty'] = $product->get_stock_quantity();
|
259 |
$data['qty'] = ( empty( $data['qty'] ) ) ? 0 : intval( $data['qty'] );
|
260 |
+
|
261 |
+
$wpdb->query( // phpcs:ignore
|
262 |
+
$wpdb->prepare( // phpcs:ignore
|
263 |
+
"INSERT INTO {$wpdb->prefix}stock_log ( date_created, product_id, qty ) VALUES ( %s, %d, %d ) ",
|
264 |
+
$data
|
265 |
+
)
|
266 |
+
);
|
267 |
|
268 |
}
|
269 |
|
270 |
+
}//end class
|
readme.txt
CHANGED
@@ -5,9 +5,9 @@ Author URI: https://www.storeapps.org/
|
|
5 |
Plugin URI: https://www.storeapps.org/woocommerce-plugins/?utm_source=wprepo&utm_medium=web&utm_campaign=wsm_readme
|
6 |
Tags: stock manager, woocommerce, stock management, inventory, products
|
7 |
Requires at least: 5.0.0
|
8 |
-
Tested up to: 5.8.
|
9 |
Requires PHP: 5.6
|
10 |
-
Stable tag: 2.
|
11 |
License: GPLv3
|
12 |
|
13 |
== Description ==
|
@@ -152,6 +152,16 @@ Be sure, that you have active stock manager.
|
|
152 |
|
153 |
== Changelog ==
|
154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
= 2.7.0 (03.09.2021) =
|
156 |
* New: WooCommerce 5.4.2, 5.5.1, 5.6.0 compatible
|
157 |
* New: WordPress 5.8.0 compatible
|
@@ -256,6 +266,9 @@ For the changelog of earlier versions, please refer to the separate [changelog.t
|
|
256 |
|
257 |
== Upgrade Notice ==
|
258 |
|
|
|
|
|
|
|
259 |
= 2.7.0 =
|
260 |
WooCommerce 5.4.2, 5.5.1, 5.6.0 compatible, WordPress 5.8.0 compatible, Unique action name for 'Export' to avoid conflicts, Prevent exposure of export data [Thanks to WordPress.org team], Strengthen security during export and subscribe process [Thanks to WordPress.org team], Automate versioning, Code cleanup, Plugin name, POT file
|
261 |
|
5 |
Plugin URI: https://www.storeapps.org/woocommerce-plugins/?utm_source=wprepo&utm_medium=web&utm_campaign=wsm_readme
|
6 |
Tags: stock manager, woocommerce, stock management, inventory, products
|
7 |
Requires at least: 5.0.0
|
8 |
+
Tested up to: 5.8.1
|
9 |
Requires PHP: 5.6
|
10 |
+
Stable tag: 2.8.0
|
11 |
License: GPLv3
|
12 |
|
13 |
== Description ==
|
152 |
|
153 |
== Changelog ==
|
154 |
|
155 |
+
= 2.8.0 (17.09.2021) =
|
156 |
+
* New: WordPress Coding Standards
|
157 |
+
* Fix: Variation product link not opening parent variable product on Stock log page
|
158 |
+
* Fix: Incorrect plugin slug and text domain at few places
|
159 |
+
* Fix: Plugin name broken in admin footer text on Stock Manager pages
|
160 |
+
* Update: Check product instance before calling product functions
|
161 |
+
* Update: Stock log page
|
162 |
+
* Update: Removed unused code
|
163 |
+
* Update: POT file
|
164 |
+
|
165 |
= 2.7.0 (03.09.2021) =
|
166 |
* New: WooCommerce 5.4.2, 5.5.1, 5.6.0 compatible
|
167 |
* New: WordPress 5.8.0 compatible
|
266 |
|
267 |
== Upgrade Notice ==
|
268 |
|
269 |
+
= 2.8.0 =
|
270 |
+
WordPress Coding Standards, Variation product link not opening parent variable product on Stock log page, Incorrect plugin slug and text domain at few places, Plugin name broken in admin footer text on Stock Manager pages, Check product instance before calling product functions, Stock log page, Removed unused code, POT file
|
271 |
+
|
272 |
= 2.7.0 =
|
273 |
WooCommerce 5.4.2, 5.5.1, 5.6.0 compatible, WordPress 5.8.0 compatible, Unique action name for 'Export' to avoid conflicts, Prevent exposure of export data [Thanks to WordPress.org team], Strengthen security during export and subscribe process [Thanks to WordPress.org team], Automate versioning, Code cleanup, Plugin name, POT file
|
274 |
|
sa-includes/class-sa-in-app-offers.php
CHANGED
@@ -3,8 +3,7 @@
|
|
3 |
* Stock Manager in app offers
|
4 |
*
|
5 |
* @package woocommerce-stock-manager/sa-includes/
|
6 |
-
* @version 1.2.
|
7 |
-
*
|
8 |
*/
|
9 |
|
10 |
// Exit if accessed directly.
|
@@ -127,7 +126,7 @@ class SA_In_App_Offers {
|
|
127 |
$end = strtotime( $this->end );
|
128 |
if ( ( $current_date >= $start ) && ( $current_date <= $end ) ) {
|
129 |
$option_value = get_option( $this->option_name, '' );
|
130 |
-
$get_post_type =
|
131 |
|
132 |
if ( ( 'product' === $get_post_type || $this->is_plugin_page ) && '' === $option_value ) {
|
133 |
return true;
|
3 |
* Stock Manager in app offers
|
4 |
*
|
5 |
* @package woocommerce-stock-manager/sa-includes/
|
6 |
+
* @version 1.2.1
|
|
|
7 |
*/
|
8 |
|
9 |
// Exit if accessed directly.
|
126 |
$end = strtotime( $this->end );
|
127 |
if ( ( $current_date >= $start ) && ( $current_date <= $end ) ) {
|
128 |
$option_value = get_option( $this->option_name, '' );
|
129 |
+
$get_post_type = ( ! empty( $_GET['post_type'] ) ) ? wc_clean( wp_unslash( $_GET['post_type'] ) ) : ''; // phpcs:ignore
|
130 |
|
131 |
if ( ( 'product' === $get_post_type || $this->is_plugin_page ) && '' === $option_value ) {
|
132 |
return true;
|
vendor/autoload.php
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// autoload.php @generated by Composer
|
4 |
-
|
5 |
-
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
-
|
7 |
-
return ComposerAutoloaderInit61649fac88544a173986d28a0bc0bc23::getLoader();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/.editorconfig
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
# editorconfig.org
|
2 |
-
root = true
|
3 |
-
|
4 |
-
[*]
|
5 |
-
charset = utf-8
|
6 |
-
end_of_line = lf
|
7 |
-
indent_size = 4
|
8 |
-
tab_width = 4
|
9 |
-
indent_style = space
|
10 |
-
insert_final_newline = true
|
11 |
-
trim_trailing_whitespace = true
|
12 |
-
|
13 |
-
[*.{md,txt,json,yml}]
|
14 |
-
trim_trailing_whitespace = false
|
15 |
-
|
16 |
-
[*.{json,yml}]
|
17 |
-
insert_final_newline = false
|
18 |
-
indent_size = 2
|
19 |
-
tab_width = 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/.gitignore
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
composer.lock
|
2 |
-
vendor/
|
3 |
-
run.php
|
|
|
|
|
|
vendor/automattic/woocommerce/.scrutinizer.yml
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
checks:
|
2 |
-
php: true
|
3 |
-
|
4 |
-
filter:
|
5 |
-
excluded_paths:
|
6 |
-
- tests/*
|
7 |
-
|
8 |
-
tools:
|
9 |
-
sensiolabs_security_checker: true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/.travis.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
language: php
|
2 |
-
|
3 |
-
sudo: false
|
4 |
-
|
5 |
-
php:
|
6 |
-
- 5.4
|
7 |
-
- 5.5
|
8 |
-
- 5.6
|
9 |
-
- 7.0
|
10 |
-
- 7.1
|
11 |
-
- 7.2
|
12 |
-
- 7.3
|
13 |
-
|
14 |
-
install:
|
15 |
-
- travis_retry composer install --no-interaction --prefer-source
|
16 |
-
|
17 |
-
script:
|
18 |
-
- vendor/bin/phpunit --verbose --coverage-text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
The MIT License (MIT)
|
2 |
-
|
3 |
-
Copyright (c) 2016, Automattic (https://automattic.com/)
|
4 |
-
|
5 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
-
of this software and associated documentation files (the "Software"), to deal
|
7 |
-
in the Software without restriction, including without limitation the rights
|
8 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
-
copies of the Software, and to permit persons to whom the Software is
|
10 |
-
furnished to do so, subject to the following conditions:
|
11 |
-
|
12 |
-
The above copyright notice and this permission notice shall be included in
|
13 |
-
all copies or substantial portions of the Software.
|
14 |
-
|
15 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
-
THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/README.md
DELETED
@@ -1,158 +0,0 @@
|
|
1 |
-
# WooCommerce API - PHP Client
|
2 |
-
|
3 |
-
A PHP wrapper for the WooCommerce REST API. Easily interact with the WooCommerce REST API securely using this library. If using a HTTPS connection this library uses BasicAuth, else it uses Oauth to provide a secure connection to WooCommerce.
|
4 |
-
|
5 |
-
[![build status](https://secure.travis-ci.org/woocommerce/wc-api-php.svg)](http://travis-ci.org/woocommerce/wc-api-php)
|
6 |
-
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/woocommerce/wc-api-php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/woocommerce/wc-api-php/?branch=master)
|
7 |
-
[![PHP version](https://badge.fury.io/ph/automattic%2Fwoocommerce.svg)](https://packagist.org/packages/automattic/woocommerce)
|
8 |
-
|
9 |
-
## Installation
|
10 |
-
|
11 |
-
```
|
12 |
-
composer require automattic/woocommerce
|
13 |
-
```
|
14 |
-
|
15 |
-
## Getting started
|
16 |
-
|
17 |
-
Generate API credentials (Consumer Key & Consumer Secret) following this instructions <http://docs.woocommerce.com/document/woocommerce-rest-api/>
|
18 |
-
.
|
19 |
-
|
20 |
-
Check out the WooCommerce API endpoints and data that can be manipulated in <https://woocommerce.github.io/woocommerce-rest-api-docs/>.
|
21 |
-
|
22 |
-
## Setup
|
23 |
-
|
24 |
-
Setup for the new WP REST API integration (WooCommerce 2.6 or later):
|
25 |
-
|
26 |
-
```php
|
27 |
-
require __DIR__ . '/vendor/autoload.php';
|
28 |
-
|
29 |
-
use Automattic\WooCommerce\Client;
|
30 |
-
|
31 |
-
$woocommerce = new Client(
|
32 |
-
'http://example.com',
|
33 |
-
'ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
|
34 |
-
'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
|
35 |
-
[
|
36 |
-
'version' => 'wc/v3',
|
37 |
-
]
|
38 |
-
);
|
39 |
-
```
|
40 |
-
|
41 |
-
## Client class
|
42 |
-
|
43 |
-
```php
|
44 |
-
$woocommerce = new Client($url, $consumer_key, $consumer_secret, $options)
|
45 |
-
```
|
46 |
-
|
47 |
-
### Options
|
48 |
-
|
49 |
-
| Option | Type | Required | Description |
|
50 |
-
|-------------------|----------|----------|--------------------------------------------|
|
51 |
-
| `url` | `string` | yes | Your Store URL, example: http://woo.dev/ |
|
52 |
-
| `consumer_key` | `string` | yes | Your API consumer key |
|
53 |
-
| `consumer_secret` | `string` | yes | Your API consumer secret |
|
54 |
-
| `options` | `array` | no | Extra arguments (see client options table) |
|
55 |
-
|
56 |
-
#### Client options
|
57 |
-
|
58 |
-
| Option | Type | Required | Description |
|
59 |
-
|---------------------|----------|----------|------------------------------------------------------------------------------------------------------------------------|
|
60 |
-
| `version` | `string` | no | API version, default is `wc/v3` |
|
61 |
-
| `timeout` | `int` | no | Request timeout, default is `15` |
|
62 |
-
| `verify_ssl` | `bool` | no | Verify SSL when connect, use this option as `false` when need to test with self-signed certificates, default is `true` |
|
63 |
-
| `follow_redirects` | `bool` | no | Allow the API call to follow redirects |
|
64 |
-
| `query_string_auth` | `bool` | no | Force Basic Authentication as query string when `true` and using under HTTPS, default is `false` |
|
65 |
-
| `oauth_timestamp` | `string` | no | Custom oAuth timestamp, default is `time()` |
|
66 |
-
| `user_agent` | `string` | no | Custom user-agent, default is `WooCommerce API Client-PHP` |
|
67 |
-
| `wp_api_prefix` | `string` | no | Custom WP REST API URL prefix, used to support custom prefixes created with the `rest_url_prefix` filter |
|
68 |
-
| `wp_api` | `bool` | no | Set to `false` in order to use the legacy WooCommerce REST API (deprecated and not recommended) |
|
69 |
-
|
70 |
-
## Client methods
|
71 |
-
|
72 |
-
### GET
|
73 |
-
|
74 |
-
```php
|
75 |
-
$woocommerce->get($endpoint, $parameters = [])
|
76 |
-
```
|
77 |
-
|
78 |
-
### POST
|
79 |
-
|
80 |
-
```php
|
81 |
-
$woocommerce->post($endpoint, $data)
|
82 |
-
```
|
83 |
-
|
84 |
-
### PUT
|
85 |
-
|
86 |
-
```php
|
87 |
-
$woocommerce->put($endpoint, $data)
|
88 |
-
```
|
89 |
-
|
90 |
-
### DELETE
|
91 |
-
|
92 |
-
```php
|
93 |
-
$woocommerce->delete($endpoint, $parameters = [])
|
94 |
-
```
|
95 |
-
|
96 |
-
### OPTIONS
|
97 |
-
|
98 |
-
```php
|
99 |
-
$woocommerce->options($endpoint)
|
100 |
-
```
|
101 |
-
|
102 |
-
#### Arguments
|
103 |
-
|
104 |
-
| Params | Type | Description |
|
105 |
-
|--------------|----------|--------------------------------------------------------------|
|
106 |
-
| `endpoint` | `string` | WooCommerce API endpoint, example: `customers` or `order/12` |
|
107 |
-
| `data` | `array` | Only for POST and PUT, data that will be converted to JSON |
|
108 |
-
| `parameters` | `array` | Only for GET and DELETE, request query string |
|
109 |
-
|
110 |
-
#### Response
|
111 |
-
|
112 |
-
All methods will return arrays on success or throwing `HttpClientException` errors on failure.
|
113 |
-
|
114 |
-
```php
|
115 |
-
use Automattic\WooCommerce\HttpClient\HttpClientException;
|
116 |
-
|
117 |
-
try {
|
118 |
-
// Array of response results.
|
119 |
-
$results = $woocommerce->get('customers');
|
120 |
-
// Example: ['customers' => [[ 'id' => 8, 'created_at' => '2015-05-06T17:43:51Z', 'email' => ...
|
121 |
-
echo '<pre><code>' . print_r( $results, true ) . '</code><pre>'; // JSON output.
|
122 |
-
|
123 |
-
// Last request data.
|
124 |
-
$lastRequest = $woocommerce->http->getRequest();
|
125 |
-
echo '<pre><code>' . print_r( $lastRequest->getUrl(), true ) . '</code><pre>'; // Requested URL (string).
|
126 |
-
echo '<pre><code>' . print_r( $lastRequest->getMethod(), true ) . '</code><pre>'; // Request method (string).
|
127 |
-
echo '<pre><code>' . print_r( $lastRequest->getParameters(), true ) . '</code><pre>'; // Request parameters (array).
|
128 |
-
echo '<pre><code>' . print_r( $lastRequest->getHeaders(), true ) . '</code><pre>'; // Request headers (array).
|
129 |
-
echo '<pre><code>' . print_r( $lastRequest->getBody(), true ) . '</code><pre>'; // Request body (JSON).
|
130 |
-
|
131 |
-
// Last response data.
|
132 |
-
$lastResponse = $woocommerce->http->getResponse();
|
133 |
-
echo '<pre><code>' . print_r( $lastResponse->getCode(), true ) . '</code><pre>'; // Response code (int).
|
134 |
-
echo '<pre><code>' . print_r( $lastResponse->getHeaders(), true ) . '</code><pre>'; // Response headers (array).
|
135 |
-
echo '<pre><code>' . print_r( $lastResponse->getBody(), true ) . '</code><pre>'; // Response body (JSON).
|
136 |
-
|
137 |
-
} catch (HttpClientException $e) {
|
138 |
-
echo '<pre><code>' . print_r( $e->getMessage(), true ) . '</code><pre>'; // Error message.
|
139 |
-
echo '<pre><code>' . print_r( $e->getRequest(), true ) . '</code><pre>'; // Last request data.
|
140 |
-
echo '<pre><code>' . print_r( $e->getResponse(), true ) . '</code><pre>'; // Last response data.
|
141 |
-
}
|
142 |
-
```
|
143 |
-
|
144 |
-
## Release History
|
145 |
-
|
146 |
-
- 2019-01-16 - 3.0.0 - Legacy API turned off by default, and improved JSON error handler.
|
147 |
-
- 2018-03-29 - 2.0.1 - Fixed fatal errors on `lookForErrors`.
|
148 |
-
- 2018-01-12 - 2.0.0 - Responses changes from arrays to `stdClass` objects. Added `follow_redirects` option.
|
149 |
-
- 2017-06-06 - 1.3.0 - Remove BOM before decoding and added support for multi-dimensional arrays for oAuth1.0a.
|
150 |
-
- 2017-03-15 - 1.2.0 - Added `user_agent` option.
|
151 |
-
- 2016-12-14 - 1.1.4 - Fixed WordPress 4.7 compatibility.
|
152 |
-
- 2016-10-26 - 1.1.3 - Allow set `oauth_timestamp` and improved how is handled the response headers.
|
153 |
-
- 2016-09-30 - 1.1.2 - Added `wp_api_prefix` option to allow custom WP REST API URL prefix.
|
154 |
-
- 2016-05-10 - 1.1.1 - Fixed oAuth and error handler for WP REST API.
|
155 |
-
- 2016-05-09 - 1.1.0 - Added support for WP REST API, added method `Automattic\WooCommerce\Client::options` and fixed multiple headers responses.
|
156 |
-
- 2016-01-25 - 1.0.2 - Fixed an error when getting data containing non-latin characters.
|
157 |
-
- 2016-01-21 - 1.0.1 - Sort all oAuth parameters before build request URLs.
|
158 |
-
- 2016-01-11 - 1.0.0 - Stable release.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/composer.json
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"name": "automattic/woocommerce",
|
3 |
-
"description": "A PHP wrapper for the WooCommerce REST API",
|
4 |
-
"type": "library",
|
5 |
-
"license": "MIT",
|
6 |
-
"authors": [
|
7 |
-
{
|
8 |
-
"name": "Claudio Sanches",
|
9 |
-
"email": "claudio.sanches@automattic.com"
|
10 |
-
}
|
11 |
-
],
|
12 |
-
"keywords": [
|
13 |
-
"API",
|
14 |
-
"WooCommerce"
|
15 |
-
],
|
16 |
-
"require": {
|
17 |
-
"php": ">= 5.4.0",
|
18 |
-
"ext-curl": "*",
|
19 |
-
"ext-json": "*"
|
20 |
-
},
|
21 |
-
"require-dev": {
|
22 |
-
"phpunit/phpunit": "*",
|
23 |
-
"squizlabs/php_codesniffer": "3.*"
|
24 |
-
},
|
25 |
-
"autoload": {
|
26 |
-
"psr-4": {
|
27 |
-
"Automattic\\WooCommerce\\": ["src/WooCommerce"]
|
28 |
-
}
|
29 |
-
},
|
30 |
-
"autoload-dev": {
|
31 |
-
"psr-4": { "Automattic\\WooCommerce\\Tests\\": "tests/WooCommerce" }
|
32 |
-
}
|
33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/phpcs.xml
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<ruleset name="WooCommerce REST API - PHP Library">
|
3 |
-
<description>The coding standard for WooCommerce REST API - PHP Library.</description>
|
4 |
-
|
5 |
-
<file>src</file>
|
6 |
-
<rule ref="PSR2" />
|
7 |
-
</ruleset>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/phpunit.xml.dist
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<phpunit bootstrap="tests/bootstrap.php"
|
3 |
-
colors="true"
|
4 |
-
convertErrorsToExceptions="true"
|
5 |
-
convertNoticesToExceptions="true"
|
6 |
-
convertWarningsToExceptions="true"
|
7 |
-
verbose="true"
|
8 |
-
stopOnFailure="false"
|
9 |
-
processIsolation="false"
|
10 |
-
backupGlobals="false"
|
11 |
-
syntaxCheck="true">
|
12 |
-
<testsuite>
|
13 |
-
<directory>./tests/WooCommerce</directory>
|
14 |
-
</testsuite>
|
15 |
-
<filter>
|
16 |
-
<whitelist addUncoveredFilesFromWhitelist="true">
|
17 |
-
<directory suffix=".php">src/</directory>
|
18 |
-
</whitelist>
|
19 |
-
</filter>
|
20 |
-
</phpunit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/src/WooCommerce/Client.php
DELETED
@@ -1,109 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WooCommerce REST API Client
|
4 |
-
*
|
5 |
-
* @category Client
|
6 |
-
* @package Automattic/WooCommerce
|
7 |
-
*/
|
8 |
-
|
9 |
-
namespace Automattic\WooCommerce;
|
10 |
-
|
11 |
-
use Automattic\WooCommerce\HttpClient\HttpClient;
|
12 |
-
|
13 |
-
/**
|
14 |
-
* REST API Client class.
|
15 |
-
*
|
16 |
-
* @package Automattic/WooCommerce
|
17 |
-
*/
|
18 |
-
class Client
|
19 |
-
{
|
20 |
-
|
21 |
-
/**
|
22 |
-
* WooCommerce REST API Client version.
|
23 |
-
*/
|
24 |
-
const VERSION = '3.0.0';
|
25 |
-
|
26 |
-
/**
|
27 |
-
* HttpClient instance.
|
28 |
-
*
|
29 |
-
* @var HttpClient
|
30 |
-
*/
|
31 |
-
public $http;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Initialize client.
|
35 |
-
*
|
36 |
-
* @param string $url Store URL.
|
37 |
-
* @param string $consumerKey Consumer key.
|
38 |
-
* @param string $consumerSecret Consumer secret.
|
39 |
-
* @param array $options Options (version, timeout, verify_ssl).
|
40 |
-
*/
|
41 |
-
public function __construct($url, $consumerKey, $consumerSecret, $options = [])
|
42 |
-
{
|
43 |
-
$this->http = new HttpClient($url, $consumerKey, $consumerSecret, $options);
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* POST method.
|
48 |
-
*
|
49 |
-
* @param string $endpoint API endpoint.
|
50 |
-
* @param array $data Request data.
|
51 |
-
*
|
52 |
-
* @return array
|
53 |
-
*/
|
54 |
-
public function post($endpoint, $data)
|
55 |
-
{
|
56 |
-
return $this->http->request($endpoint, 'POST', $data);
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* PUT method.
|
61 |
-
*
|
62 |
-
* @param string $endpoint API endpoint.
|
63 |
-
* @param array $data Request data.
|
64 |
-
*
|
65 |
-
* @return array
|
66 |
-
*/
|
67 |
-
public function put($endpoint, $data)
|
68 |
-
{
|
69 |
-
return $this->http->request($endpoint, 'PUT', $data);
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* GET method.
|
74 |
-
*
|
75 |
-
* @param string $endpoint API endpoint.
|
76 |
-
* @param array $parameters Request parameters.
|
77 |
-
*
|
78 |
-
* @return array
|
79 |
-
*/
|
80 |
-
public function get($endpoint, $parameters = [])
|
81 |
-
{
|
82 |
-
return $this->http->request($endpoint, 'GET', [], $parameters);
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* DELETE method.
|
87 |
-
*
|
88 |
-
* @param string $endpoint API endpoint.
|
89 |
-
* @param array $parameters Request parameters.
|
90 |
-
*
|
91 |
-
* @return array
|
92 |
-
*/
|
93 |
-
public function delete($endpoint, $parameters = [])
|
94 |
-
{
|
95 |
-
return $this->http->request($endpoint, 'DELETE', [], $parameters);
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* OPTIONS method.
|
100 |
-
*
|
101 |
-
* @param string $endpoint API endpoint.
|
102 |
-
*
|
103 |
-
* @return array
|
104 |
-
*/
|
105 |
-
public function options($endpoint)
|
106 |
-
{
|
107 |
-
return $this->http->request($endpoint, 'OPTIONS', [], []);
|
108 |
-
}
|
109 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/src/WooCommerce/HttpClient/BasicAuth.php
DELETED
@@ -1,95 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WooCommerce Basic Authentication
|
4 |
-
*
|
5 |
-
* @category HttpClient
|
6 |
-
* @package Automattic/WooCommerce
|
7 |
-
*/
|
8 |
-
|
9 |
-
namespace Automattic\WooCommerce\HttpClient;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Basic Authentication class.
|
13 |
-
*
|
14 |
-
* @package Automattic/WooCommerce
|
15 |
-
*/
|
16 |
-
class BasicAuth
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* cURL handle.
|
20 |
-
*
|
21 |
-
* @var resource
|
22 |
-
*/
|
23 |
-
protected $ch;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Consumer key.
|
27 |
-
*
|
28 |
-
* @var string
|
29 |
-
*/
|
30 |
-
protected $consumerKey;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Consumer secret.
|
34 |
-
*
|
35 |
-
* @var string
|
36 |
-
*/
|
37 |
-
protected $consumerSecret;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Do query string auth.
|
41 |
-
*
|
42 |
-
* @var bool
|
43 |
-
*/
|
44 |
-
protected $doQueryString;
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Request parameters.
|
48 |
-
*
|
49 |
-
* @var array
|
50 |
-
*/
|
51 |
-
protected $parameters;
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Initialize Basic Authentication class.
|
55 |
-
*
|
56 |
-
* @param resource $ch cURL handle.
|
57 |
-
* @param string $consumerKey Consumer key.
|
58 |
-
* @param string $consumerSecret Consumer Secret.
|
59 |
-
* @param bool $doQueryString Do or not query string auth.
|
60 |
-
* @param array $parameters Request parameters.
|
61 |
-
*/
|
62 |
-
public function __construct($ch, $consumerKey, $consumerSecret, $doQueryString, $parameters = [])
|
63 |
-
{
|
64 |
-
$this->ch = $ch;
|
65 |
-
$this->consumerKey = $consumerKey;
|
66 |
-
$this->consumerSecret = $consumerSecret;
|
67 |
-
$this->doQueryString = $doQueryString;
|
68 |
-
$this->parameters = $parameters;
|
69 |
-
|
70 |
-
$this->processAuth();
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Process auth.
|
75 |
-
*/
|
76 |
-
protected function processAuth()
|
77 |
-
{
|
78 |
-
if ($this->doQueryString) {
|
79 |
-
$this->parameters['consumer_key'] = $this->consumerKey;
|
80 |
-
$this->parameters['consumer_secret'] = $this->consumerSecret;
|
81 |
-
} else {
|
82 |
-
\curl_setopt($this->ch, CURLOPT_USERPWD, $this->consumerKey . ':' . $this->consumerSecret);
|
83 |
-
}
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Get parameters.
|
88 |
-
*
|
89 |
-
* @return array
|
90 |
-
*/
|
91 |
-
public function getParameters()
|
92 |
-
{
|
93 |
-
return $this->parameters;
|
94 |
-
}
|
95 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php
DELETED
@@ -1,444 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WooCommerce REST API HTTP Client
|
4 |
-
*
|
5 |
-
* @category HttpClient
|
6 |
-
* @package Automattic/WooCommerce
|
7 |
-
*/
|
8 |
-
|
9 |
-
namespace Automattic\WooCommerce\HttpClient;
|
10 |
-
|
11 |
-
use Automattic\WooCommerce\Client;
|
12 |
-
use Automattic\WooCommerce\HttpClient\BasicAuth;
|
13 |
-
use Automattic\WooCommerce\HttpClient\HttpClientException;
|
14 |
-
use Automattic\WooCommerce\HttpClient\OAuth;
|
15 |
-
use Automattic\WooCommerce\HttpClient\Options;
|
16 |
-
use Automattic\WooCommerce\HttpClient\Request;
|
17 |
-
use Automattic\WooCommerce\HttpClient\Response;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* REST API HTTP Client class.
|
21 |
-
*
|
22 |
-
* @package Automattic/WooCommerce
|
23 |
-
*/
|
24 |
-
class HttpClient
|
25 |
-
{
|
26 |
-
|
27 |
-
/**
|
28 |
-
* cURL handle.
|
29 |
-
*
|
30 |
-
* @var resource
|
31 |
-
*/
|
32 |
-
protected $ch;
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Store API URL.
|
36 |
-
*
|
37 |
-
* @var string
|
38 |
-
*/
|
39 |
-
protected $url;
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Consumer key.
|
43 |
-
*
|
44 |
-
* @var string
|
45 |
-
*/
|
46 |
-
protected $consumerKey;
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Consumer secret.
|
50 |
-
*
|
51 |
-
* @var string
|
52 |
-
*/
|
53 |
-
protected $consumerSecret;
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Client options.
|
57 |
-
*
|
58 |
-
* @var Options
|
59 |
-
*/
|
60 |
-
protected $options;
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Request.
|
64 |
-
*
|
65 |
-
* @var Request
|
66 |
-
*/
|
67 |
-
private $request;
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Response.
|
71 |
-
*
|
72 |
-
* @var Response
|
73 |
-
*/
|
74 |
-
private $response;
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Response headers.
|
78 |
-
*
|
79 |
-
* @var string
|
80 |
-
*/
|
81 |
-
private $responseHeaders;
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Initialize HTTP client.
|
85 |
-
*
|
86 |
-
* @param string $url Store URL.
|
87 |
-
* @param string $consumerKey Consumer key.
|
88 |
-
* @param string $consumerSecret Consumer Secret.
|
89 |
-
* @param array $options Client options.
|
90 |
-
*/
|
91 |
-
public function __construct($url, $consumerKey, $consumerSecret, $options)
|
92 |
-
{
|
93 |
-
if (!\function_exists('curl_version')) {
|
94 |
-
throw new HttpClientException('cURL is NOT installed on this server', -1, new Request(), new Response());
|
95 |
-
}
|
96 |
-
|
97 |
-
$this->options = new Options($options);
|
98 |
-
$this->url = $this->buildApiUrl($url);
|
99 |
-
$this->consumerKey = $consumerKey;
|
100 |
-
$this->consumerSecret = $consumerSecret;
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Check if is under SSL.
|
105 |
-
*
|
106 |
-
* @return bool
|
107 |
-
*/
|
108 |
-
protected function isSsl()
|
109 |
-
{
|
110 |
-
return 'https://' === \substr($this->url, 0, 8);
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Build API URL.
|
115 |
-
*
|
116 |
-
* @param string $url Store URL.
|
117 |
-
*
|
118 |
-
* @return string
|
119 |
-
*/
|
120 |
-
protected function buildApiUrl($url)
|
121 |
-
{
|
122 |
-
$api = $this->options->isWPAPI() ? $this->options->apiPrefix() : '/wc-api/';
|
123 |
-
|
124 |
-
return \rtrim($url, '/') . $api . $this->options->getVersion() . '/';
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* Build URL.
|
129 |
-
*
|
130 |
-
* @param string $url URL.
|
131 |
-
* @param array $parameters Query string parameters.
|
132 |
-
*
|
133 |
-
* @return string
|
134 |
-
*/
|
135 |
-
protected function buildUrlQuery($url, $parameters = [])
|
136 |
-
{
|
137 |
-
if (!empty($parameters)) {
|
138 |
-
$url .= '?' . \http_build_query($parameters);
|
139 |
-
}
|
140 |
-
|
141 |
-
return $url;
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* Authenticate.
|
146 |
-
*
|
147 |
-
* @param string $url Request URL.
|
148 |
-
* @param string $method Request method.
|
149 |
-
* @param array $parameters Request parameters.
|
150 |
-
*
|
151 |
-
* @return array
|
152 |
-
*/
|
153 |
-
protected function authenticate($url, $method, $parameters = [])
|
154 |
-
{
|
155 |
-
// Setup authentication.
|
156 |
-
if ($this->isSsl()) {
|
157 |
-
$basicAuth = new BasicAuth(
|
158 |
-
$this->ch,
|
159 |
-
$this->consumerKey,
|
160 |
-
$this->consumerSecret,
|
161 |
-
$this->options->isQueryStringAuth(),
|
162 |
-
$parameters
|
163 |
-
);
|
164 |
-
$parameters = $basicAuth->getParameters();
|
165 |
-
} else {
|
166 |
-
$oAuth = new OAuth(
|
167 |
-
$url,
|
168 |
-
$this->consumerKey,
|
169 |
-
$this->consumerSecret,
|
170 |
-
$this->options->getVersion(),
|
171 |
-
$method,
|
172 |
-
$parameters,
|
173 |
-
$this->options->oauthTimestamp()
|
174 |
-
);
|
175 |
-
$parameters = $oAuth->getParameters();
|
176 |
-
}
|
177 |
-
|
178 |
-
return $parameters;
|
179 |
-
}
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Setup method.
|
183 |
-
*
|
184 |
-
* @param string $method Request method.
|
185 |
-
*/
|
186 |
-
protected function setupMethod($method)
|
187 |
-
{
|
188 |
-
if ('POST' == $method) {
|
189 |
-
\curl_setopt($this->ch, CURLOPT_POST, true);
|
190 |
-
} elseif (\in_array($method, ['PUT', 'DELETE', 'OPTIONS'])) {
|
191 |
-
\curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, $method);
|
192 |
-
}
|
193 |
-
}
|
194 |
-
|
195 |
-
/**
|
196 |
-
* Get request headers.
|
197 |
-
*
|
198 |
-
* @param bool $sendData If request send data or not.
|
199 |
-
*
|
200 |
-
* @return array
|
201 |
-
*/
|
202 |
-
protected function getRequestHeaders($sendData = false)
|
203 |
-
{
|
204 |
-
$headers = [
|
205 |
-
'Accept' => 'application/json',
|
206 |
-
'User-Agent' => $this->options->userAgent() . '/' . Client::VERSION,
|
207 |
-
];
|
208 |
-
|
209 |
-
if ($sendData) {
|
210 |
-
$headers['Content-Type'] = 'application/json;charset=utf-8';
|
211 |
-
}
|
212 |
-
|
213 |
-
return $headers;
|
214 |
-
}
|
215 |
-
|
216 |
-
/**
|
217 |
-
* Create request.
|
218 |
-
*
|
219 |
-
* @param string $endpoint Request endpoint.
|
220 |
-
* @param string $method Request method.
|
221 |
-
* @param array $data Request data.
|
222 |
-
* @param array $parameters Request parameters.
|
223 |
-
*
|
224 |
-
* @return Request
|
225 |
-
*/
|
226 |
-
protected function createRequest($endpoint, $method, $data = [], $parameters = [])
|
227 |
-
{
|
228 |
-
$body = '';
|
229 |
-
$url = $this->url . $endpoint;
|
230 |
-
$hasData = !empty($data);
|
231 |
-
|
232 |
-
// Setup authentication.
|
233 |
-
$parameters = $this->authenticate($url, $method, $parameters);
|
234 |
-
|
235 |
-
// Setup method.
|
236 |
-
$this->setupMethod($method);
|
237 |
-
|
238 |
-
// Include post fields.
|
239 |
-
if ($hasData) {
|
240 |
-
$body = \json_encode($data);
|
241 |
-
\curl_setopt($this->ch, CURLOPT_POSTFIELDS, $body);
|
242 |
-
}
|
243 |
-
|
244 |
-
$this->request = new Request(
|
245 |
-
$this->buildUrlQuery($url, $parameters),
|
246 |
-
$method,
|
247 |
-
$parameters,
|
248 |
-
$this->getRequestHeaders($hasData),
|
249 |
-
$body
|
250 |
-
);
|
251 |
-
|
252 |
-
return $this->getRequest();
|
253 |
-
}
|
254 |
-
|
255 |
-
/**
|
256 |
-
* Get response headers.
|
257 |
-
*
|
258 |
-
* @return array
|
259 |
-
*/
|
260 |
-
protected function getResponseHeaders()
|
261 |
-
{
|
262 |
-
$headers = [];
|
263 |
-
$lines = \explode("\n", $this->responseHeaders);
|
264 |
-
$lines = \array_filter($lines, 'trim');
|
265 |
-
|
266 |
-
foreach ($lines as $index => $line) {
|
267 |
-
// Remove HTTP/xxx params.
|
268 |
-
if (strpos($line, ': ') === false) {
|
269 |
-
continue;
|
270 |
-
}
|
271 |
-
|
272 |
-
list($key, $value) = \explode(': ', $line);
|
273 |
-
|
274 |
-
$headers[$key] = isset($headers[$key]) ? $headers[$key] . ', ' . trim($value) : trim($value);
|
275 |
-
}
|
276 |
-
|
277 |
-
return $headers;
|
278 |
-
}
|
279 |
-
|
280 |
-
/**
|
281 |
-
* Create response.
|
282 |
-
*
|
283 |
-
* @return Response
|
284 |
-
*/
|
285 |
-
protected function createResponse()
|
286 |
-
{
|
287 |
-
|
288 |
-
// Set response headers.
|
289 |
-
$this->responseHeaders = '';
|
290 |
-
\curl_setopt($this->ch, CURLOPT_HEADERFUNCTION, function ($_, $headers) {
|
291 |
-
$this->responseHeaders .= $headers;
|
292 |
-
return \strlen($headers);
|
293 |
-
});
|
294 |
-
|
295 |
-
// Get response data.
|
296 |
-
$body = \curl_exec($this->ch);
|
297 |
-
$code = \curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
|
298 |
-
$headers = $this->getResponseHeaders();
|
299 |
-
|
300 |
-
// Register response.
|
301 |
-
$this->response = new Response($code, $headers, $body);
|
302 |
-
|
303 |
-
return $this->getResponse();
|
304 |
-
}
|
305 |
-
|
306 |
-
/**
|
307 |
-
* Set default cURL settings.
|
308 |
-
*/
|
309 |
-
protected function setDefaultCurlSettings()
|
310 |
-
{
|
311 |
-
$verifySsl = $this->options->verifySsl();
|
312 |
-
$timeout = $this->options->getTimeout();
|
313 |
-
$followRedirects = $this->options->getFollowRedirects();
|
314 |
-
|
315 |
-
\curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, $verifySsl);
|
316 |
-
if (!$verifySsl) {
|
317 |
-
\curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, $verifySsl);
|
318 |
-
}
|
319 |
-
if ($followRedirects) {
|
320 |
-
\curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);
|
321 |
-
}
|
322 |
-
\curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, $timeout);
|
323 |
-
\curl_setopt($this->ch, CURLOPT_TIMEOUT, $timeout);
|
324 |
-
\curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
|
325 |
-
\curl_setopt($this->ch, CURLOPT_HTTPHEADER, $this->request->getRawHeaders());
|
326 |
-
\curl_setopt($this->ch, CURLOPT_URL, $this->request->getUrl());
|
327 |
-
}
|
328 |
-
|
329 |
-
/**
|
330 |
-
* Look for errors in the request.
|
331 |
-
*
|
332 |
-
* @param array $parsedResponse Parsed body response.
|
333 |
-
*/
|
334 |
-
protected function lookForErrors($parsedResponse)
|
335 |
-
{
|
336 |
-
// Any non-200/201/202 response code indicates an error.
|
337 |
-
if (!\in_array($this->response->getCode(), ['200', '201', '202'])) {
|
338 |
-
$errors = isset($parsedResponse->errors) ? $parsedResponse->errors : $parsedResponse;
|
339 |
-
$errorMessage = '';
|
340 |
-
$errorCode = '';
|
341 |
-
|
342 |
-
if (is_array($errors)) {
|
343 |
-
$errorMessage = $errors[0]->message;
|
344 |
-
$errorCode = $errors[0]->code;
|
345 |
-
} elseif (isset($errors->message, $errors->code)) {
|
346 |
-
$errorMessage = $errors->message;
|
347 |
-
$errorCode = $errors->code;
|
348 |
-
}
|
349 |
-
|
350 |
-
throw new HttpClientException(
|
351 |
-
\sprintf('Error: %s [%s]', $errorMessage, $errorCode),
|
352 |
-
$this->response->getCode(),
|
353 |
-
$this->request,
|
354 |
-
$this->response
|
355 |
-
);
|
356 |
-
}
|
357 |
-
}
|
358 |
-
|
359 |
-
/**
|
360 |
-
* Process response.
|
361 |
-
*
|
362 |
-
* @return array
|
363 |
-
*/
|
364 |
-
protected function processResponse()
|
365 |
-
{
|
366 |
-
$body = $this->response->getBody();
|
367 |
-
|
368 |
-
// Look for UTF-8 BOM and remove.
|
369 |
-
if (0 === strpos(bin2hex(substr($body, 0, 4)), 'efbbbf')) {
|
370 |
-
$body = substr($body, 3);
|
371 |
-
}
|
372 |
-
|
373 |
-
$parsedResponse = \json_decode($body);
|
374 |
-
|
375 |
-
// Test if return a valid JSON.
|
376 |
-
if (JSON_ERROR_NONE !== json_last_error()) {
|
377 |
-
$message = function_exists('json_last_error_msg') ? json_last_error_msg() : 'Invalid JSON returned';
|
378 |
-
throw new HttpClientException(
|
379 |
-
sprintf('JSON ERROR: %s', $message),
|
380 |
-
$this->response->getCode(),
|
381 |
-
$this->request,
|
382 |
-
$this->response
|
383 |
-
);
|
384 |
-
}
|
385 |
-
|
386 |
-
$this->lookForErrors($parsedResponse);
|
387 |
-
|
388 |
-
return $parsedResponse;
|
389 |
-
}
|
390 |
-
|
391 |
-
/**
|
392 |
-
* Make requests.
|
393 |
-
*
|
394 |
-
* @param string $endpoint Request endpoint.
|
395 |
-
* @param string $method Request method.
|
396 |
-
* @param array $data Request data.
|
397 |
-
* @param array $parameters Request parameters.
|
398 |
-
*
|
399 |
-
* @return array
|
400 |
-
*/
|
401 |
-
public function request($endpoint, $method, $data = [], $parameters = [])
|
402 |
-
{
|
403 |
-
// Initialize cURL.
|
404 |
-
$this->ch = \curl_init();
|
405 |
-
|
406 |
-
// Set request args.
|
407 |
-
$request = $this->createRequest($endpoint, $method, $data, $parameters);
|
408 |
-
|
409 |
-
// Default cURL settings.
|
410 |
-
$this->setDefaultCurlSettings();
|
411 |
-
|
412 |
-
// Get response.
|
413 |
-
$response = $this->createResponse();
|
414 |
-
|
415 |
-
// Check for cURL errors.
|
416 |
-
if (\curl_errno($this->ch)) {
|
417 |
-
throw new HttpClientException('cURL Error: ' . \curl_error($this->ch), 0, $request, $response);
|
418 |
-
}
|
419 |
-
|
420 |
-
\curl_close($this->ch);
|
421 |
-
|
422 |
-
return $this->processResponse();
|
423 |
-
}
|
424 |
-
|
425 |
-
/**
|
426 |
-
* Get request data.
|
427 |
-
*
|
428 |
-
* @return Request
|
429 |
-
*/
|
430 |
-
public function getRequest()
|
431 |
-
{
|
432 |
-
return $this->request;
|
433 |
-
}
|
434 |
-
|
435 |
-
/**
|
436 |
-
* Get response data.
|
437 |
-
*
|
438 |
-
* @return Response
|
439 |
-
*/
|
440 |
-
public function getResponse()
|
441 |
-
{
|
442 |
-
return $this->response;
|
443 |
-
}
|
444 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClientException.php
DELETED
@@ -1,70 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WooCommerce REST API HTTP Client Exception
|
4 |
-
*
|
5 |
-
* @category HttpClient
|
6 |
-
* @package Automattic/WooCommerce
|
7 |
-
*/
|
8 |
-
|
9 |
-
namespace Automattic\WooCommerce\HttpClient;
|
10 |
-
|
11 |
-
use Automattic\WooCommerce\HttpClient\Request;
|
12 |
-
use Automattic\WooCommerce\HttpClient\Response;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* REST API HTTP Client Exception class.
|
16 |
-
*
|
17 |
-
* @package Automattic/WooCommerce
|
18 |
-
*/
|
19 |
-
class HttpClientException extends \Exception
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* Request.
|
23 |
-
*
|
24 |
-
* @var Request
|
25 |
-
*/
|
26 |
-
private $request;
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Response.
|
30 |
-
*
|
31 |
-
* @var Response
|
32 |
-
*/
|
33 |
-
private $response;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Initialize exception.
|
37 |
-
*
|
38 |
-
* @param string $message Error message.
|
39 |
-
* @param int $code Error code.
|
40 |
-
* @param Request $request Request data.
|
41 |
-
* @param Response $response Response data.
|
42 |
-
*/
|
43 |
-
public function __construct($message, $code, Request $request, Response $response)
|
44 |
-
{
|
45 |
-
parent::__construct($message, $code);
|
46 |
-
|
47 |
-
$this->request = $request;
|
48 |
-
$this->response = $response;
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Get request data.
|
53 |
-
*
|
54 |
-
* @return Request
|
55 |
-
*/
|
56 |
-
public function getRequest()
|
57 |
-
{
|
58 |
-
return $this->request;
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Get response data.
|
63 |
-
*
|
64 |
-
* @return Response
|
65 |
-
*/
|
66 |
-
public function getResponse()
|
67 |
-
{
|
68 |
-
return $this->response;
|
69 |
-
}
|
70 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/src/WooCommerce/HttpClient/OAuth.php
DELETED
@@ -1,268 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WooCommerce oAuth1.0
|
4 |
-
*
|
5 |
-
* @category HttpClient
|
6 |
-
* @package Automattic/WooCommerce
|
7 |
-
*/
|
8 |
-
|
9 |
-
namespace Automattic\WooCommerce\HttpClient;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* oAuth1.0 class.
|
13 |
-
*
|
14 |
-
* @package Automattic/WooCommerce
|
15 |
-
*/
|
16 |
-
class OAuth
|
17 |
-
{
|
18 |
-
|
19 |
-
/**
|
20 |
-
* OAuth signature method algorithm.
|
21 |
-
*/
|
22 |
-
const HASH_ALGORITHM = 'SHA256';
|
23 |
-
|
24 |
-
/**
|
25 |
-
* API endpoint URL.
|
26 |
-
*
|
27 |
-
* @var string
|
28 |
-
*/
|
29 |
-
protected $url;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Consumer key.
|
33 |
-
*
|
34 |
-
* @var string
|
35 |
-
*/
|
36 |
-
protected $consumerKey;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Consumer secret.
|
40 |
-
*
|
41 |
-
* @var string
|
42 |
-
*/
|
43 |
-
protected $consumerSecret;
|
44 |
-
|
45 |
-
/**
|
46 |
-
* API version.
|
47 |
-
*
|
48 |
-
* @var string
|
49 |
-
*/
|
50 |
-
protected $apiVersion;
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Request method.
|
54 |
-
*
|
55 |
-
* @var string
|
56 |
-
*/
|
57 |
-
protected $method;
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Request parameters.
|
61 |
-
*
|
62 |
-
* @var array
|
63 |
-
*/
|
64 |
-
protected $parameters;
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Timestamp.
|
68 |
-
*
|
69 |
-
* @var string
|
70 |
-
*/
|
71 |
-
protected $timestamp;
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Initialize oAuth class.
|
75 |
-
*
|
76 |
-
* @param string $url Store URL.
|
77 |
-
* @param string $consumerKey Consumer key.
|
78 |
-
* @param string $consumerSecret Consumer Secret.
|
79 |
-
* @param string $method Request method.
|
80 |
-
* @param string $apiVersion API version.
|
81 |
-
* @param array $parameters Request parameters.
|
82 |
-
* @param string $timestamp Timestamp.
|
83 |
-
*/
|
84 |
-
public function __construct(
|
85 |
-
$url,
|
86 |
-
$consumerKey,
|
87 |
-
$consumerSecret,
|
88 |
-
$apiVersion,
|
89 |
-
$method,
|
90 |
-
$parameters = [],
|
91 |
-
$timestamp = ''
|
92 |
-
) {
|
93 |
-
$this->url = $url;
|
94 |
-
$this->consumerKey = $consumerKey;
|
95 |
-
$this->consumerSecret = $consumerSecret;
|
96 |
-
$this->apiVersion = $apiVersion;
|
97 |
-
$this->method = $method;
|
98 |
-
$this->parameters = $parameters;
|
99 |
-
$this->timestamp = $timestamp;
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Encode according to RFC 3986.
|
104 |
-
*
|
105 |
-
* @param string|array $value Value to be normalized.
|
106 |
-
*
|
107 |
-
* @return string
|
108 |
-
*/
|
109 |
-
protected function encode($value)
|
110 |
-
{
|
111 |
-
if (is_array($value)) {
|
112 |
-
return array_map([$this, 'encode'], $value);
|
113 |
-
} else {
|
114 |
-
return str_replace(['+', '%7E'], [' ', '~'], rawurlencode($value));
|
115 |
-
}
|
116 |
-
}
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Normalize parameters.
|
120 |
-
*
|
121 |
-
* @param array $parameters Parameters to normalize.
|
122 |
-
*
|
123 |
-
* @return array
|
124 |
-
*/
|
125 |
-
protected function normalizeParameters($parameters)
|
126 |
-
{
|
127 |
-
$normalized = [];
|
128 |
-
|
129 |
-
foreach ($parameters as $key => $value) {
|
130 |
-
// Percent symbols (%) must be double-encoded.
|
131 |
-
$key = $this->encode($key);
|
132 |
-
$value = $this->encode($value);
|
133 |
-
|
134 |
-
$normalized[$key] = $value;
|
135 |
-
}
|
136 |
-
|
137 |
-
return $normalized;
|
138 |
-
}
|
139 |
-
|
140 |
-
/**
|
141 |
-
* Process filters.
|
142 |
-
*
|
143 |
-
* @param array $parameters Request parameters.
|
144 |
-
*
|
145 |
-
* @return array
|
146 |
-
*/
|
147 |
-
protected function processFilters($parameters)
|
148 |
-
{
|
149 |
-
if (isset($parameters['filter'])) {
|
150 |
-
$filters = $parameters['filter'];
|
151 |
-
unset($parameters['filter']);
|
152 |
-
foreach ($filters as $filter => $value) {
|
153 |
-
$parameters['filter[' . $filter . ']'] = $value;
|
154 |
-
}
|
155 |
-
}
|
156 |
-
|
157 |
-
return $parameters;
|
158 |
-
}
|
159 |
-
|
160 |
-
/**
|
161 |
-
* Get secret.
|
162 |
-
*
|
163 |
-
* @return string
|
164 |
-
*/
|
165 |
-
protected function getSecret()
|
166 |
-
{
|
167 |
-
$secret = $this->consumerSecret;
|
168 |
-
|
169 |
-
// Fix secret for v3 or later.
|
170 |
-
if (!\in_array($this->apiVersion, ['v1', 'v2'])) {
|
171 |
-
$secret .= '&';
|
172 |
-
}
|
173 |
-
|
174 |
-
return $secret;
|
175 |
-
}
|
176 |
-
|
177 |
-
/**
|
178 |
-
* Generate oAuth1.0 signature.
|
179 |
-
*
|
180 |
-
* @param array $parameters Request parameters including oauth.
|
181 |
-
*
|
182 |
-
* @return string
|
183 |
-
*/
|
184 |
-
protected function generateOauthSignature($parameters)
|
185 |
-
{
|
186 |
-
$baseRequestUri = \rawurlencode($this->url);
|
187 |
-
|
188 |
-
// Extract filters.
|
189 |
-
$parameters = $this->processFilters($parameters);
|
190 |
-
|
191 |
-
// Normalize parameter key/values and sort them.
|
192 |
-
$parameters = $this->normalizeParameters($parameters);
|
193 |
-
\uksort($parameters, 'strcmp');
|
194 |
-
|
195 |
-
// Set query string.
|
196 |
-
$queryString = \implode('%26', $this->joinWithEqualsSign($parameters)); // Join with ampersand.
|
197 |
-
$stringToSign = $this->method . '&' . $baseRequestUri . '&' . $queryString;
|
198 |
-
$secret = $this->getSecret();
|
199 |
-
|
200 |
-
return \base64_encode(\hash_hmac(self::HASH_ALGORITHM, $stringToSign, $secret, true));
|
201 |
-
}
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Creates an array of urlencoded strings out of each array key/value pairs.
|
205 |
-
*
|
206 |
-
* @param array $params Array of parameters to convert.
|
207 |
-
* @param array $queryParams Array to extend.
|
208 |
-
* @param string $key Optional Array key to append
|
209 |
-
* @return string Array of urlencoded strings
|
210 |
-
*/
|
211 |
-
protected function joinWithEqualsSign($params, $queryParams = [], $key = '')
|
212 |
-
{
|
213 |
-
foreach ($params as $paramKey => $paramValue) {
|
214 |
-
if ($key) {
|
215 |
-
$paramKey = $key . '%5B' . $paramKey . '%5D'; // Handle multi-dimensional array.
|
216 |
-
}
|
217 |
-
|
218 |
-
if (is_array($paramValue)) {
|
219 |
-
$queryParams = $this->joinWithEqualsSign($paramValue, $queryParams, $paramKey);
|
220 |
-
} else {
|
221 |
-
$string = $paramKey . '=' . $paramValue; // Join with equals sign.
|
222 |
-
$queryParams[] = $this->encode($string);
|
223 |
-
}
|
224 |
-
}
|
225 |
-
|
226 |
-
return $queryParams;
|
227 |
-
}
|
228 |
-
|
229 |
-
/**
|
230 |
-
* Sort parameters.
|
231 |
-
*
|
232 |
-
* @param array $parameters Parameters to sort in byte-order.
|
233 |
-
*
|
234 |
-
* @return array
|
235 |
-
*/
|
236 |
-
protected function getSortedParameters($parameters)
|
237 |
-
{
|
238 |
-
\uksort($parameters, 'strcmp');
|
239 |
-
|
240 |
-
foreach ($parameters as $key => $value) {
|
241 |
-
if (\is_array($value)) {
|
242 |
-
\uksort($parameters[$key], 'strcmp');
|
243 |
-
}
|
244 |
-
}
|
245 |
-
|
246 |
-
return $parameters;
|
247 |
-
}
|
248 |
-
|
249 |
-
/**
|
250 |
-
* Get oAuth1.0 parameters.
|
251 |
-
*
|
252 |
-
* @return string
|
253 |
-
*/
|
254 |
-
public function getParameters()
|
255 |
-
{
|
256 |
-
$parameters = \array_merge($this->parameters, [
|
257 |
-
'oauth_consumer_key' => $this->consumerKey,
|
258 |
-
'oauth_timestamp' => $this->timestamp,
|
259 |
-
'oauth_nonce' => \sha1(\microtime()),
|
260 |
-
'oauth_signature_method' => 'HMAC-' . self::HASH_ALGORITHM,
|
261 |
-
]);
|
262 |
-
|
263 |
-
// The parameters above must be included in the signature generation.
|
264 |
-
$parameters['oauth_signature'] = $this->generateOauthSignature($parameters);
|
265 |
-
|
266 |
-
return $this->getSortedParameters($parameters);
|
267 |
-
}
|
268 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/src/WooCommerce/HttpClient/Options.php
DELETED
@@ -1,148 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WooCommerce REST API HTTP Client Options
|
4 |
-
*
|
5 |
-
* @category HttpClient
|
6 |
-
* @package Automattic/WooCommerce
|
7 |
-
*/
|
8 |
-
|
9 |
-
namespace Automattic\WooCommerce\HttpClient;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* REST API HTTP Client Options class.
|
13 |
-
*
|
14 |
-
* @package Automattic/WooCommerce
|
15 |
-
*/
|
16 |
-
class Options
|
17 |
-
{
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Default WooCommerce REST API version.
|
21 |
-
*/
|
22 |
-
const VERSION = 'wc/v3';
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Default request timeout.
|
26 |
-
*/
|
27 |
-
const TIMEOUT = 15;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Default WP API prefix.
|
31 |
-
* Including leading and trailing slashes.
|
32 |
-
*/
|
33 |
-
const WP_API_PREFIX = '/wp-json/';
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Default User Agent.
|
37 |
-
* No version number.
|
38 |
-
*/
|
39 |
-
const USER_AGENT = 'WooCommerce API Client-PHP';
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Options.
|
43 |
-
*
|
44 |
-
* @var array
|
45 |
-
*/
|
46 |
-
private $options;
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Initialize HTTP client options.
|
50 |
-
*
|
51 |
-
* @param array $options Client options.
|
52 |
-
*/
|
53 |
-
public function __construct($options)
|
54 |
-
{
|
55 |
-
$this->options = $options;
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Get API version.
|
60 |
-
*
|
61 |
-
* @return string
|
62 |
-
*/
|
63 |
-
public function getVersion()
|
64 |
-
{
|
65 |
-
return isset($this->options['version']) ? $this->options['version'] : self::VERSION;
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Check if need to verify SSL.
|
70 |
-
*
|
71 |
-
* @return bool
|
72 |
-
*/
|
73 |
-
public function verifySsl()
|
74 |
-
{
|
75 |
-
return isset($this->options['verify_ssl']) ? (bool) $this->options['verify_ssl'] : true;
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Get timeout.
|
80 |
-
*
|
81 |
-
* @return int
|
82 |
-
*/
|
83 |
-
public function getTimeout()
|
84 |
-
{
|
85 |
-
return isset($this->options['timeout']) ? (int) $this->options['timeout'] : self::TIMEOUT;
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Basic Authentication as query string.
|
90 |
-
* Some old servers are not able to use CURLOPT_USERPWD.
|
91 |
-
*
|
92 |
-
* @return bool
|
93 |
-
*/
|
94 |
-
public function isQueryStringAuth()
|
95 |
-
{
|
96 |
-
return isset($this->options['query_string_auth']) ? (bool) $this->options['query_string_auth'] : false;
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* Check if is WP REST API.
|
101 |
-
*
|
102 |
-
* @return bool
|
103 |
-
*/
|
104 |
-
public function isWPAPI()
|
105 |
-
{
|
106 |
-
return isset($this->options['wp_api']) ? (bool) $this->options['wp_api'] : true;
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Custom API Prefix for WP API.
|
111 |
-
*
|
112 |
-
* @return string
|
113 |
-
*/
|
114 |
-
public function apiPrefix()
|
115 |
-
{
|
116 |
-
return isset($this->options['wp_api_prefix']) ? $this->options['wp_api_prefix'] : self::WP_API_PREFIX;
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* oAuth timestamp.
|
121 |
-
*
|
122 |
-
* @return string
|
123 |
-
*/
|
124 |
-
public function oauthTimestamp()
|
125 |
-
{
|
126 |
-
return isset($this->options['oauth_timestamp']) ? $this->options['oauth_timestamp'] : \time();
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Custom user agent.
|
131 |
-
*
|
132 |
-
* @return string
|
133 |
-
*/
|
134 |
-
public function userAgent()
|
135 |
-
{
|
136 |
-
return isset($this->options['user_agent']) ? $this->options['user_agent'] : self::USER_AGENT;
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* Get follow redirects
|
141 |
-
*
|
142 |
-
* @return bool
|
143 |
-
*/
|
144 |
-
public function getFollowRedirects()
|
145 |
-
{
|
146 |
-
return isset($this->options['follow_redirects']) ? (bool) $this->options['follow_redirects'] : false;
|
147 |
-
}
|
148 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/src/WooCommerce/HttpClient/Request.php
DELETED
@@ -1,187 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WooCommerce REST API HTTP Client Request
|
4 |
-
*
|
5 |
-
* @category HttpClient
|
6 |
-
* @package Automattic/WooCommerce
|
7 |
-
*/
|
8 |
-
|
9 |
-
namespace Automattic\WooCommerce\HttpClient;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* REST API HTTP Client Request class.
|
13 |
-
*
|
14 |
-
* @package Automattic/WooCommerce
|
15 |
-
*/
|
16 |
-
class Request
|
17 |
-
{
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Request url.
|
21 |
-
*
|
22 |
-
* @var string
|
23 |
-
*/
|
24 |
-
private $url;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Request method.
|
28 |
-
*
|
29 |
-
* @var string
|
30 |
-
*/
|
31 |
-
private $method;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Request paramenters.
|
35 |
-
*
|
36 |
-
* @var array
|
37 |
-
*/
|
38 |
-
private $parameters;
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Request headers.
|
42 |
-
*
|
43 |
-
* @var array
|
44 |
-
*/
|
45 |
-
private $headers;
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Request body.
|
49 |
-
*
|
50 |
-
* @var string
|
51 |
-
*/
|
52 |
-
private $body;
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Initialize request.
|
56 |
-
*
|
57 |
-
* @param string $url Request url.
|
58 |
-
* @param string $method Request method.
|
59 |
-
* @param array $parameters Request paramenters.
|
60 |
-
* @param array $headers Request headers.
|
61 |
-
* @param string $body Request body.
|
62 |
-
*/
|
63 |
-
public function __construct($url = '', $method = 'POST', $parameters = [], $headers = [], $body = '')
|
64 |
-
{
|
65 |
-
$this->url = $url;
|
66 |
-
$this->method = $method;
|
67 |
-
$this->parameters = $parameters;
|
68 |
-
$this->headers = $headers;
|
69 |
-
$this->body = $body;
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Set url.
|
74 |
-
*
|
75 |
-
* @param string $url Request url.
|
76 |
-
*/
|
77 |
-
public function setUrl($url)
|
78 |
-
{
|
79 |
-
$this->url = $url;
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Set method.
|
84 |
-
*
|
85 |
-
* @param string $method Request method.
|
86 |
-
*/
|
87 |
-
public function setMethod($method)
|
88 |
-
{
|
89 |
-
$this->method = $method;
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Set parameters.
|
94 |
-
*
|
95 |
-
* @param array $parameters Request paramenters.
|
96 |
-
*/
|
97 |
-
public function setParameters($parameters)
|
98 |
-
{
|
99 |
-
$this->parameters = $parameters;
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Set headers.
|
104 |
-
*
|
105 |
-
* @param array $headers Request headers.
|
106 |
-
*/
|
107 |
-
public function setHeaders($headers)
|
108 |
-
{
|
109 |
-
$this->headers = $headers;
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Set body.
|
114 |
-
*
|
115 |
-
* @param string $body Request body.
|
116 |
-
*/
|
117 |
-
public function setBody($body)
|
118 |
-
{
|
119 |
-
$this->body = $body;
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Get url.
|
124 |
-
*
|
125 |
-
* @return string
|
126 |
-
*/
|
127 |
-
public function getUrl()
|
128 |
-
{
|
129 |
-
return $this->url;
|
130 |
-
}
|
131 |
-
|
132 |
-
/**
|
133 |
-
* Get method.
|
134 |
-
*
|
135 |
-
* @return string
|
136 |
-
*/
|
137 |
-
public function getMethod()
|
138 |
-
{
|
139 |
-
return $this->method;
|
140 |
-
}
|
141 |
-
|
142 |
-
/**
|
143 |
-
* Get parameters.
|
144 |
-
*
|
145 |
-
* @return array
|
146 |
-
*/
|
147 |
-
public function getParameters()
|
148 |
-
{
|
149 |
-
return $this->parameters;
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* Get headers.
|
154 |
-
*
|
155 |
-
* @return array
|
156 |
-
*/
|
157 |
-
public function getHeaders()
|
158 |
-
{
|
159 |
-
return $this->headers;
|
160 |
-
}
|
161 |
-
|
162 |
-
/**
|
163 |
-
* Get raw headers.
|
164 |
-
*
|
165 |
-
* @return array
|
166 |
-
*/
|
167 |
-
public function getRawHeaders()
|
168 |
-
{
|
169 |
-
$headers = [];
|
170 |
-
|
171 |
-
foreach ($this->headers as $key => $value) {
|
172 |
-
$headers[] = $key . ': ' . $value;
|
173 |
-
}
|
174 |
-
|
175 |
-
return $headers;
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Get body.
|
180 |
-
*
|
181 |
-
* @return string
|
182 |
-
*/
|
183 |
-
public function getBody()
|
184 |
-
{
|
185 |
-
return $this->body;
|
186 |
-
}
|
187 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/src/WooCommerce/HttpClient/Response.php
DELETED
@@ -1,113 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WooCommerce REST API HTTP Client Response
|
4 |
-
*
|
5 |
-
* @category HttpClient
|
6 |
-
* @package Automattic/WooCommerce
|
7 |
-
*/
|
8 |
-
|
9 |
-
namespace Automattic\WooCommerce\HttpClient;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* REST API HTTP Client Response class.
|
13 |
-
*
|
14 |
-
* @package Automattic/WooCommerce
|
15 |
-
*/
|
16 |
-
class Response
|
17 |
-
{
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Response code.
|
21 |
-
*
|
22 |
-
* @var int
|
23 |
-
*/
|
24 |
-
private $code;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Response headers.
|
28 |
-
*
|
29 |
-
* @var array
|
30 |
-
*/
|
31 |
-
private $headers;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Response body.
|
35 |
-
*
|
36 |
-
* @var string
|
37 |
-
*/
|
38 |
-
private $body;
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Initialize response.
|
42 |
-
*
|
43 |
-
* @param int $code Response code.
|
44 |
-
* @param array $headers Response headers.
|
45 |
-
* @param string $body Response body.
|
46 |
-
*/
|
47 |
-
public function __construct($code = 0, $headers = [], $body = '')
|
48 |
-
{
|
49 |
-
$this->code = $code;
|
50 |
-
$this->headers = $headers;
|
51 |
-
$this->body = $body;
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Set code.
|
56 |
-
*
|
57 |
-
* @param int $code Response code.
|
58 |
-
*/
|
59 |
-
public function setCode($code)
|
60 |
-
{
|
61 |
-
$this->code = (int) $code;
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Set headers.
|
66 |
-
*
|
67 |
-
* @param array $headers Response headers.
|
68 |
-
*/
|
69 |
-
public function setHeaders($headers)
|
70 |
-
{
|
71 |
-
$this->headers = $headers;
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Set body.
|
76 |
-
*
|
77 |
-
* @param string $body Response body.
|
78 |
-
*/
|
79 |
-
public function setBody($body)
|
80 |
-
{
|
81 |
-
$this->body = $body;
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Get code.
|
86 |
-
*
|
87 |
-
* @return int
|
88 |
-
*/
|
89 |
-
public function getCode()
|
90 |
-
{
|
91 |
-
return $this->code;
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Get headers.
|
96 |
-
*
|
97 |
-
* @return array $headers Response headers.
|
98 |
-
*/
|
99 |
-
public function getHeaders()
|
100 |
-
{
|
101 |
-
return $this->headers;
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Get body.
|
106 |
-
*
|
107 |
-
* @return string $body Response body.
|
108 |
-
*/
|
109 |
-
public function getBody()
|
110 |
-
{
|
111 |
-
return $this->body;
|
112 |
-
}
|
113 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/tests/WooCommerce/Tests/ClientTest.php
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Automattic\WooCommerce\Tests;
|
4 |
-
|
5 |
-
use \PHPUnit\Framework\TestCase as TestCase;
|
6 |
-
|
7 |
-
class ClientTest extends TestCase
|
8 |
-
{
|
9 |
-
|
10 |
-
public function testHttpInstanceOfHttpClient()
|
11 |
-
{
|
12 |
-
$client = new \Automattic\WooCommerce\Client('', '', '');
|
13 |
-
|
14 |
-
$this->assertInstanceOf('Automattic\\WooCommerce\\HttpClient\\HttpClient', $client->http);
|
15 |
-
}
|
16 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/tests/WooCommerce/Tests/HttpClient/BasicAuthTest.php
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Automattic\WooCommerce\Tests;
|
4 |
-
|
5 |
-
use \PHPUnit\Framework\TestCase as TestCase;
|
6 |
-
|
7 |
-
class BasicAuthTest extends TestCase
|
8 |
-
{
|
9 |
-
|
10 |
-
protected $basicAuth;
|
11 |
-
|
12 |
-
public function setUp()
|
13 |
-
{
|
14 |
-
$this->basicAuth = new \Automattic\WooCommerce\HttpClient\BasicAuth(null, 'ck_xxx', 'cs_xxx', true);
|
15 |
-
}
|
16 |
-
|
17 |
-
public function testGetParameters()
|
18 |
-
{
|
19 |
-
$default = [
|
20 |
-
'consumer_key' => 'ck_xxx',
|
21 |
-
'consumer_secret' => 'cs_xxx',
|
22 |
-
];
|
23 |
-
|
24 |
-
$this->assertEquals($default, $this->basicAuth->getParameters());
|
25 |
-
}
|
26 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/tests/WooCommerce/Tests/HttpClient/HttpClientExceptionTest.php
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Automattic\WooCommerce\Tests;
|
4 |
-
|
5 |
-
use \PHPUnit\Framework\TestCase as TestCase;
|
6 |
-
|
7 |
-
class HttpClientExceptionTest extends TestCase
|
8 |
-
{
|
9 |
-
|
10 |
-
protected $exception;
|
11 |
-
|
12 |
-
public function setUp()
|
13 |
-
{
|
14 |
-
$request = new \Automattic\WooCommerce\HttpClient\Request();
|
15 |
-
$response = new \Automattic\WooCommerce\HttpClient\Response();
|
16 |
-
|
17 |
-
$this->exception = new \Automattic\WooCommerce\HttpClient\HttpClientException('Test', 200, $request, $response);
|
18 |
-
}
|
19 |
-
|
20 |
-
public function testInstanceOfException()
|
21 |
-
{
|
22 |
-
$this->assertInstanceOf('Exception', $this->exception);
|
23 |
-
}
|
24 |
-
|
25 |
-
public function testGetMessage()
|
26 |
-
{
|
27 |
-
$this->assertEquals('Test', $this->exception->getMessage());
|
28 |
-
}
|
29 |
-
|
30 |
-
public function testGetCode()
|
31 |
-
{
|
32 |
-
$this->assertEquals(200, $this->exception->getCode());
|
33 |
-
}
|
34 |
-
|
35 |
-
public function testGetRequest()
|
36 |
-
{
|
37 |
-
$this->assertInstanceOf('Automattic\\WooCommerce\\HttpClient\\Request', $this->exception->getRequest());
|
38 |
-
}
|
39 |
-
|
40 |
-
public function testGetResponse()
|
41 |
-
{
|
42 |
-
$this->assertInstanceOf('Automattic\\WooCommerce\\HttpClient\\Response', $this->exception->getResponse());
|
43 |
-
}
|
44 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/tests/WooCommerce/Tests/HttpClient/OAuthTest.php
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Automattic\WooCommerce\Tests;
|
4 |
-
|
5 |
-
use \PHPUnit\Framework\TestCase as TestCase;
|
6 |
-
|
7 |
-
class OAuthTest extends TestCase
|
8 |
-
{
|
9 |
-
|
10 |
-
protected $oAuth;
|
11 |
-
|
12 |
-
public function setUp()
|
13 |
-
{
|
14 |
-
$url = 'http://example.com';
|
15 |
-
$consumerKey = 'ck_xxx';
|
16 |
-
$consumerSecret = 'cs_xxx';
|
17 |
-
$this->oAuth = new \Automattic\WooCommerce\HttpClient\OAuth($url, $consumerKey, $consumerSecret, 'v3', 'POST');
|
18 |
-
}
|
19 |
-
|
20 |
-
public function testGetParameters()
|
21 |
-
{
|
22 |
-
$parameters = $this->oAuth->getParameters();
|
23 |
-
$keys = [
|
24 |
-
'oauth_consumer_key',
|
25 |
-
'oauth_nonce',
|
26 |
-
'oauth_signature',
|
27 |
-
'oauth_signature_method',
|
28 |
-
'oauth_timestamp',
|
29 |
-
];
|
30 |
-
|
31 |
-
$this->assertEquals($keys, array_keys($parameters));
|
32 |
-
$this->assertEquals('ck_xxx', $parameters['oauth_consumer_key']);
|
33 |
-
$this->assertEquals('HMAC-SHA256', $parameters['oauth_signature_method']);
|
34 |
-
}
|
35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/tests/WooCommerce/Tests/HttpClient/OptionsTest.php
DELETED
@@ -1,51 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Automattic\WooCommerce\Tests;
|
4 |
-
|
5 |
-
use \PHPUnit\Framework\TestCase as TestCase;
|
6 |
-
|
7 |
-
class OptionsTest extends TestCase
|
8 |
-
{
|
9 |
-
|
10 |
-
protected $options;
|
11 |
-
|
12 |
-
public function setUp()
|
13 |
-
{
|
14 |
-
$this->options = new \Automattic\WooCommerce\HttpClient\Options([]);
|
15 |
-
}
|
16 |
-
|
17 |
-
public function testDefaultValueOfGetVersion()
|
18 |
-
{
|
19 |
-
$this->assertEquals('wc/v3', $this->options->getVersion());
|
20 |
-
}
|
21 |
-
|
22 |
-
public function testDefaultValueOfVerifySsl()
|
23 |
-
{
|
24 |
-
$this->assertTrue($this->options->verifySsl());
|
25 |
-
}
|
26 |
-
|
27 |
-
public function testDefaultValueOfGetTimeout()
|
28 |
-
{
|
29 |
-
$this->assertEquals(15, $this->options->getTimeout());
|
30 |
-
}
|
31 |
-
|
32 |
-
public function testDefaultValueOfIsQueryStringAuth()
|
33 |
-
{
|
34 |
-
$this->assertFalse($this->options->isQueryStringAuth());
|
35 |
-
}
|
36 |
-
|
37 |
-
public function testisWPAPI()
|
38 |
-
{
|
39 |
-
$this->assertTrue($this->options->isWPAPI());
|
40 |
-
}
|
41 |
-
|
42 |
-
public function testDefaultValueOfIsApiPrefix()
|
43 |
-
{
|
44 |
-
$this->assertEquals('/wp-json/', $this->options->apiPrefix());
|
45 |
-
}
|
46 |
-
|
47 |
-
public function testDefaultValueOfUserAgent()
|
48 |
-
{
|
49 |
-
$this->assertEquals('WooCommerce API Client-PHP', $this->options->userAgent());
|
50 |
-
}
|
51 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/tests/WooCommerce/Tests/HttpClient/RequestTest.php
DELETED
@@ -1,65 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Automattic\WooCommerce\Tests;
|
4 |
-
|
5 |
-
use \PHPUnit\Framework\TestCase as TestCase;
|
6 |
-
|
7 |
-
class RequestTest extends TestCase
|
8 |
-
{
|
9 |
-
|
10 |
-
protected $request;
|
11 |
-
|
12 |
-
public function setUp()
|
13 |
-
{
|
14 |
-
$this->request = new \Automattic\WooCommerce\HttpClient\Request();
|
15 |
-
}
|
16 |
-
|
17 |
-
public function testUrl()
|
18 |
-
{
|
19 |
-
$url = 'http://example.com';
|
20 |
-
$this->request->setUrl($url);
|
21 |
-
|
22 |
-
$this->assertEquals($url, $this->request->getUrl());
|
23 |
-
}
|
24 |
-
|
25 |
-
public function testMethod()
|
26 |
-
{
|
27 |
-
$method = 'PUT';
|
28 |
-
$this->request->setMethod($method);
|
29 |
-
|
30 |
-
$this->assertEquals($method, $this->request->getMethod());
|
31 |
-
}
|
32 |
-
|
33 |
-
public function testParameters()
|
34 |
-
{
|
35 |
-
$parameters = ['page' => 2];
|
36 |
-
$this->request->setParameters($parameters);
|
37 |
-
|
38 |
-
$this->assertEquals($parameters, $this->request->getParameters());
|
39 |
-
}
|
40 |
-
|
41 |
-
public function testHeaders()
|
42 |
-
{
|
43 |
-
$headers = ['Content-Type' => 'application/json'];
|
44 |
-
$this->request->setHeaders($headers);
|
45 |
-
|
46 |
-
$this->assertEquals($headers, $this->request->getHeaders());
|
47 |
-
}
|
48 |
-
|
49 |
-
public function testRawHeaders()
|
50 |
-
{
|
51 |
-
$headers = ['Content-Type' => 'application/json'];
|
52 |
-
$this->request->setHeaders($headers);
|
53 |
-
$rawHeaders = ['Content-Type: application/json'];
|
54 |
-
|
55 |
-
$this->assertEquals($rawHeaders, $this->request->getRawHeaders());
|
56 |
-
}
|
57 |
-
|
58 |
-
public function testBody()
|
59 |
-
{
|
60 |
-
$body = '{"product": {"id": 1}}';
|
61 |
-
$this->request->setBody($body);
|
62 |
-
|
63 |
-
$this->assertEquals($body, $this->request->getBody());
|
64 |
-
}
|
65 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/tests/WooCommerce/Tests/HttpClient/ResponseTest.php
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Automattic\WooCommerce\Tests;
|
4 |
-
|
5 |
-
use \PHPUnit\Framework\TestCase as TestCase;
|
6 |
-
|
7 |
-
class ResponseTest extends TestCase
|
8 |
-
{
|
9 |
-
|
10 |
-
protected $response;
|
11 |
-
|
12 |
-
public function setUp()
|
13 |
-
{
|
14 |
-
$this->response = new \Automattic\WooCommerce\HttpClient\Response();
|
15 |
-
}
|
16 |
-
|
17 |
-
public function testCode()
|
18 |
-
{
|
19 |
-
$code = 200;
|
20 |
-
$this->response->setCode($code);
|
21 |
-
|
22 |
-
$this->assertEquals($code, $this->response->getCode());
|
23 |
-
}
|
24 |
-
|
25 |
-
public function testHeaders()
|
26 |
-
{
|
27 |
-
$headers = ['Content-Type' => 'application/json'];
|
28 |
-
$this->response->setHeaders($headers);
|
29 |
-
|
30 |
-
$this->assertEquals($headers, $this->response->getHeaders());
|
31 |
-
}
|
32 |
-
|
33 |
-
public function testBody()
|
34 |
-
{
|
35 |
-
$body = '{"product": {"id": 1}}';
|
36 |
-
$this->response->setBody($body);
|
37 |
-
|
38 |
-
$this->assertEquals($body, $this->response->getBody());
|
39 |
-
}
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/automattic/woocommerce/tests/bootstrap.php
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Tests for WooCommerce REST API PHP-Client.
|
4 |
-
*
|
5 |
-
* @category Tests
|
6 |
-
* @package Automattic/WooCommerce/Tests
|
7 |
-
*/
|
8 |
-
|
9 |
-
function includeIfExists($file)
|
10 |
-
{
|
11 |
-
if (file_exists($file)) {
|
12 |
-
return include $file;
|
13 |
-
}
|
14 |
-
}
|
15 |
-
|
16 |
-
if ((!$loader = includeIfExists(__DIR__ . '/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__ . '/../../../.composer/autoload.php'))) {
|
17 |
-
die('You must set up the project dependencies, run the following commands:' . PHP_EOL . 'curl -s http://getcomposer.org/installer | php' . PHP_EOL . 'php composer.phar install' . PHP_EOL);
|
18 |
-
}
|
19 |
-
|
20 |
-
$loader->add('WooCommerce\Tests', __DIR__);
|
21 |
-
|
22 |
-
return $loader;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/composer/ClassLoader.php
DELETED
@@ -1,441 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of Composer.
|
5 |
-
*
|
6 |
-
* (c) Nils Adermann <naderman@naderman.de>
|
7 |
-
* Jordi Boggiano <j.boggiano@seld.be>
|
8 |
-
*
|
9 |
-
* For the full copyright and license information, please view the LICENSE
|
10 |
-
* file that was distributed with this source code.
|
11 |
-
*/
|
12 |
-
|
13 |
-
namespace Composer\Autoload;
|
14 |
-
|
15 |
-
/**
|
16 |
-
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
17 |
-
*
|
18 |
-
* $loader = new \Composer\Autoload\ClassLoader();
|
19 |
-
*
|
20 |
-
* // register classes with namespaces
|
21 |
-
* $loader->add('Symfony\Component', __DIR__.'/component');
|
22 |
-
* $loader->add('Symfony', __DIR__.'/framework');
|
23 |
-
*
|
24 |
-
* // activate the autoloader
|
25 |
-
* $loader->register();
|
26 |
-
*
|
27 |
-
* // to enable searching the include path (eg. for PEAR packages)
|
28 |
-
* $loader->setUseIncludePath(true);
|
29 |
-
*
|
30 |
-
* In this example, if you try to use a class in the Symfony\Component
|
31 |
-
* namespace or one of its children (Symfony\Component\Console for instance),
|
32 |
-
* the autoloader will first look for the class under the component/
|
33 |
-
* directory, and it will then fallback to the framework/ directory if not
|
34 |
-
* found before giving up.
|
35 |
-
*
|
36 |
-
* This class is loosely based on the Symfony UniversalClassLoader.
|
37 |
-
*
|
38 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
39 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
40 |
-
* @see http://www.php-fig.org/psr/psr-0/
|
41 |
-
* @see http://www.php-fig.org/psr/psr-4/
|
42 |
-
*/
|
43 |
-
class ClassLoader
|
44 |
-
{
|
45 |
-
// PSR-4
|
46 |
-
private $prefixLengthsPsr4 = array();
|
47 |
-
private $prefixDirsPsr4 = array();
|
48 |
-
private $fallbackDirsPsr4 = array();
|
49 |
-
|
50 |
-
// PSR-0
|
51 |
-
private $prefixesPsr0 = array();
|
52 |
-
private $fallbackDirsPsr0 = array();
|
53 |
-
|
54 |
-
private $useIncludePath = false;
|
55 |
-
private $classMap = array();
|
56 |
-
private $classMapAuthoritative = false;
|
57 |
-
private $missingClasses = array();
|
58 |
-
private $apcuPrefix;
|
59 |
-
|
60 |
-
public function getPrefixes()
|
61 |
-
{
|
62 |
-
if (!empty($this->prefixesPsr0)) {
|
63 |
-
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
64 |
-
}
|
65 |
-
|
66 |
-
return array();
|
67 |
-
}
|
68 |
-
|
69 |
-
public function getPrefixesPsr4()
|
70 |
-
{
|
71 |
-
return $this->prefixDirsPsr4;
|
72 |
-
}
|
73 |
-
|
74 |
-
public function getFallbackDirs()
|
75 |
-
{
|
76 |
-
return $this->fallbackDirsPsr0;
|
77 |
-
}
|
78 |
-
|
79 |
-
public function getFallbackDirsPsr4()
|
80 |
-
{
|
81 |
-
return $this->fallbackDirsPsr4;
|
82 |
-
}
|
83 |
-
|
84 |
-
public function getClassMap()
|
85 |
-
{
|
86 |
-
return $this->classMap;
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* @param array $classMap Class to filename map
|
91 |
-
*/
|
92 |
-
public function addClassMap(array $classMap)
|
93 |
-
{
|
94 |
-
if ($this->classMap) {
|
95 |
-
$this->classMap = array_merge($this->classMap, $classMap);
|
96 |
-
} else {
|
97 |
-
$this->classMap = $classMap;
|
98 |
-
}
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Registers a set of PSR-0 directories for a given prefix, either
|
103 |
-
* appending or prepending to the ones previously set for this prefix.
|
104 |
-
*
|
105 |
-
* @param string $prefix The prefix
|
106 |
-
* @param array|string $paths The PSR-0 root directories
|
107 |
-
* @param bool $prepend Whether to prepend the directories
|
108 |
-
*/
|
109 |
-
public function add($prefix, $paths, $prepend = false)
|
110 |
-
{
|
111 |
-
if (!$prefix) {
|
112 |
-
if ($prepend) {
|
113 |
-
$this->fallbackDirsPsr0 = array_merge(
|
114 |
-
(array) $paths,
|
115 |
-
$this->fallbackDirsPsr0
|
116 |
-
);
|
117 |
-
} else {
|
118 |
-
$this->fallbackDirsPsr0 = array_merge(
|
119 |
-
$this->fallbackDirsPsr0,
|
120 |
-
(array) $paths
|
121 |
-
);
|
122 |
-
}
|
123 |
-
|
124 |
-
return;
|
125 |
-
}
|
126 |
-
|
127 |
-
$first = $prefix[0];
|
128 |
-
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
129 |
-
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
130 |
-
|
131 |
-
return;
|
132 |
-
}
|
133 |
-
if ($prepend) {
|
134 |
-
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
135 |
-
(array) $paths,
|
136 |
-
$this->prefixesPsr0[$first][$prefix]
|
137 |
-
);
|
138 |
-
} else {
|
139 |
-
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
140 |
-
$this->prefixesPsr0[$first][$prefix],
|
141 |
-
(array) $paths
|
142 |
-
);
|
143 |
-
}
|
144 |
-
}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* Registers a set of PSR-4 directories for a given namespace, either
|
148 |
-
* appending or prepending to the ones previously set for this namespace.
|
149 |
-
*
|
150 |
-
* @param string $prefix The prefix/namespace, with trailing '\\'
|
151 |
-
* @param array|string $paths The PSR-4 base directories
|
152 |
-
* @param bool $prepend Whether to prepend the directories
|
153 |
-
*
|
154 |
-
* @throws \InvalidArgumentException
|
155 |
-
*/
|
156 |
-
public function addPsr4($prefix, $paths, $prepend = false)
|
157 |
-
{
|
158 |
-
if (!$prefix) {
|
159 |
-
// Register directories for the root namespace.
|
160 |
-
if ($prepend) {
|
161 |
-
$this->fallbackDirsPsr4 = array_merge(
|
162 |
-
(array) $paths,
|
163 |
-
$this->fallbackDirsPsr4
|
164 |
-
);
|
165 |
-
} else {
|
166 |
-
$this->fallbackDirsPsr4 = array_merge(
|
167 |
-
$this->fallbackDirsPsr4,
|
168 |
-
(array) $paths
|
169 |
-
);
|
170 |
-
}
|
171 |
-
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
172 |
-
// Register directories for a new namespace.
|
173 |
-
$length = strlen($prefix);
|
174 |
-
if ('\\' !== $prefix[$length - 1]) {
|
175 |
-
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
176 |
-
}
|
177 |
-
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
178 |
-
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
179 |
-
} elseif ($prepend) {
|
180 |
-
// Prepend directories for an already registered namespace.
|
181 |
-
$this->prefixDirsPsr4[$prefix] = array_merge(
|
182 |
-
(array) $paths,
|
183 |
-
$this->prefixDirsPsr4[$prefix]
|
184 |
-
);
|
185 |
-
} else {
|
186 |
-
// Append directories for an already registered namespace.
|
187 |
-
$this->prefixDirsPsr4[$prefix] = array_merge(
|
188 |
-
$this->prefixDirsPsr4[$prefix],
|
189 |
-
(array) $paths
|
190 |
-
);
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
/**
|
195 |
-
* Registers a set of PSR-0 directories for a given prefix,
|
196 |
-
* replacing any others previously set for this prefix.
|
197 |
-
*
|
198 |
-
* @param string $prefix The prefix
|
199 |
-
* @param array|string $paths The PSR-0 base directories
|
200 |
-
*/
|
201 |
-
public function set($prefix, $paths)
|
202 |
-
{
|
203 |
-
if (!$prefix) {
|
204 |
-
$this->fallbackDirsPsr0 = (array) $paths;
|
205 |
-
} else {
|
206 |
-
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
207 |
-
}
|
208 |
-
}
|
209 |
-
|
210 |
-
/**
|
211 |
-
* Registers a set of PSR-4 directories for a given namespace,
|
212 |
-
* replacing any others previously set for this namespace.
|
213 |
-
*
|
214 |
-
* @param string $prefix The prefix/namespace, with trailing '\\'
|
215 |
-
* @param array|string $paths The PSR-4 base directories
|
216 |
-
*
|
217 |
-
* @throws \InvalidArgumentException
|
218 |
-
*/
|
219 |
-
public function setPsr4($prefix, $paths)
|
220 |
-
{
|
221 |
-
if (!$prefix) {
|
222 |
-
$this->fallbackDirsPsr4 = (array) $paths;
|
223 |
-
} else {
|
224 |
-
$length = strlen($prefix);
|
225 |
-
if ('\\' !== $prefix[$length - 1]) {
|
226 |
-
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
227 |
-
}
|
228 |
-
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
229 |
-
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
230 |
-
}
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
* Turns on searching the include path for class files.
|
235 |
-
*
|
236 |
-
* @param bool $useIncludePath
|
237 |
-
*/
|
238 |
-
public function setUseIncludePath($useIncludePath)
|
239 |
-
{
|
240 |
-
$this->useIncludePath = $useIncludePath;
|
241 |
-
}
|
242 |
-
|
243 |
-
/**
|
244 |
-
* Can be used to check if the autoloader uses the include path to check
|
245 |
-
* for classes.
|
246 |
-
*
|
247 |
-
* @return bool
|
248 |
-
*/
|
249 |
-
public function getUseIncludePath()
|
250 |
-
{
|
251 |
-
return $this->useIncludePath;
|
252 |
-
}
|
253 |
-
|
254 |
-
/**
|
255 |
-
* Turns off searching the prefix and fallback directories for classes
|
256 |
-
* that have not been registered with the class map.
|
257 |
-
*
|
258 |
-
* @param bool $classMapAuthoritative
|
259 |
-
*/
|
260 |
-
public function setClassMapAuthoritative($classMapAuthoritative)
|
261 |
-
{
|
262 |
-
$this->classMapAuthoritative = $classMapAuthoritative;
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Should class lookup fail if not found in the current class map?
|
267 |
-
*
|
268 |
-
* @return bool
|
269 |
-
*/
|
270 |
-
public function isClassMapAuthoritative()
|
271 |
-
{
|
272 |
-
return $this->classMapAuthoritative;
|
273 |
-
}
|
274 |
-
|
275 |
-
/**
|
276 |
-
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
277 |
-
*
|
278 |
-
* @param string|null $apcuPrefix
|
279 |
-
*/
|
280 |
-
public function setApcuPrefix($apcuPrefix)
|
281 |
-
{
|
282 |
-
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
|
283 |
-
}
|
284 |
-
|
285 |
-
/**
|
286 |
-
* The APCu prefix in use, or null if APCu caching is not enabled.
|
287 |
-
*
|
288 |
-
* @return string|null
|
289 |
-
*/
|
290 |
-
public function getApcuPrefix()
|
291 |
-
{
|
292 |
-
return $this->apcuPrefix;
|
293 |
-
}
|
294 |
-
|
295 |
-
/**
|
296 |
-
* Registers this instance as an autoloader.
|
297 |
-
*
|
298 |
-
* @param bool $prepend Whether to prepend the autoloader or not
|
299 |
-
*/
|
300 |
-
public function register($prepend = false)
|
301 |
-
{
|
302 |
-
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
303 |
-
}
|
304 |
-
|
305 |
-
/**
|
306 |
-
* Unregisters this instance as an autoloader.
|
307 |
-
*/
|
308 |
-
public function unregister()
|
309 |
-
{
|
310 |
-
spl_autoload_unregister(array($this, 'loadClass'));
|
311 |
-
}
|
312 |
-
|
313 |
-
/**
|
314 |
-
* Loads the given class or interface.
|
315 |
-
*
|
316 |
-
* @param string $class The name of the class
|
317 |
-
* @return bool|null True if loaded, null otherwise
|
318 |
-
*/
|
319 |
-
public function loadClass($class)
|
320 |
-
{
|
321 |
-
if ($file = $this->findFile($class)) {
|
322 |
-
includeFile($file);
|
323 |
-
|
324 |
-
return true;
|
325 |
-
}
|
326 |
-
}
|
327 |
-
|
328 |
-
/**
|
329 |
-
* Finds the path to the file where the class is defined.
|
330 |
-
*
|
331 |
-
* @param string $class The name of the class
|
332 |
-
*
|
333 |
-
* @return string|false The path if found, false otherwise
|
334 |
-
*/
|
335 |
-
public function findFile($class)
|
336 |
-
{
|
337 |
-
// class map lookup
|
338 |
-
if (isset($this->classMap[$class])) {
|
339 |
-
return $this->classMap[$class];
|
340 |
-
}
|
341 |
-
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
342 |
-
return false;
|
343 |
-
}
|
344 |
-
if (null !== $this->apcuPrefix) {
|
345 |
-
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
346 |
-
if ($hit) {
|
347 |
-
return $file;
|
348 |
-
}
|
349 |
-
}
|
350 |
-
|
351 |
-
$file = $this->findFileWithExtension($class, '.php');
|
352 |
-
|
353 |
-
// Search for Hack files if we are running on HHVM
|
354 |
-
if (false === $file && defined('HHVM_VERSION')) {
|
355 |
-
$file = $this->findFileWithExtension($class, '.hh');
|
356 |
-
}
|
357 |
-
|
358 |
-
if (null !== $this->apcuPrefix) {
|
359 |
-
apcu_add($this->apcuPrefix.$class, $file);
|
360 |
-
}
|
361 |
-
|
362 |
-
if (false === $file) {
|
363 |
-
// Remember that this class does not exist.
|
364 |
-
$this->missingClasses[$class] = true;
|
365 |
-
}
|
366 |
-
|
367 |
-
return $file;
|
368 |
-
}
|
369 |
-
|
370 |
-
private function findFileWithExtension($class, $ext)
|
371 |
-
{
|
372 |
-
// PSR-4 lookup
|
373 |
-
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
374 |
-
|
375 |
-
$first = $class[0];
|
376 |
-
if (isset($this->prefixLengthsPsr4[$first])) {
|
377 |
-
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
|
378 |
-
if (0 === strpos($class, $prefix)) {
|
379 |
-
foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
|
380 |
-
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
|
381 |
-
return $file;
|
382 |
-
}
|
383 |
-
}
|
384 |
-
}
|
385 |
-
}
|
386 |
-
}
|
387 |
-
|
388 |
-
// PSR-4 fallback dirs
|
389 |
-
foreach ($this->fallbackDirsPsr4 as $dir) {
|
390 |
-
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
391 |
-
return $file;
|
392 |
-
}
|
393 |
-
}
|
394 |
-
|
395 |
-
// PSR-0 lookup
|
396 |
-
if (false !== $pos = strrpos($class, '\\')) {
|
397 |
-
// namespaced class name
|
398 |
-
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
399 |
-
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
400 |
-
} else {
|
401 |
-
// PEAR-like class name
|
402 |
-
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
403 |
-
}
|
404 |
-
|
405 |
-
if (isset($this->prefixesPsr0[$first])) {
|
406 |
-
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
407 |
-
if (0 === strpos($class, $prefix)) {
|
408 |
-
foreach ($dirs as $dir) {
|
409 |
-
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
410 |
-
return $file;
|
411 |
-
}
|
412 |
-
}
|
413 |
-
}
|
414 |
-
}
|
415 |
-
}
|
416 |
-
|
417 |
-
// PSR-0 fallback dirs
|
418 |
-
foreach ($this->fallbackDirsPsr0 as $dir) {
|
419 |
-
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
420 |
-
return $file;
|
421 |
-
}
|
422 |
-
}
|
423 |
-
|
424 |
-
// PSR-0 include paths.
|
425 |
-
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
426 |
-
return $file;
|
427 |
-
}
|
428 |
-
|
429 |
-
return false;
|
430 |
-
}
|
431 |
-
}
|
432 |
-
|
433 |
-
/**
|
434 |
-
* Scope isolated include.
|
435 |
-
*
|
436 |
-
* Prevents access to $this/self from included files.
|
437 |
-
*/
|
438 |
-
function includeFile($file)
|
439 |
-
{
|
440 |
-
include $file;
|
441 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/composer/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
|
2 |
-
Copyright (c) 2016 Nils Adermann, Jordi Boggiano
|
3 |
-
|
4 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5 |
-
of this software and associated documentation files (the "Software"), to deal
|
6 |
-
in the Software without restriction, including without limitation the rights
|
7 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8 |
-
copies of the Software, and to permit persons to whom the Software is furnished
|
9 |
-
to do so, subject to the following conditions:
|
10 |
-
|
11 |
-
The above copyright notice and this permission notice shall be included in all
|
12 |
-
copies or substantial portions of the Software.
|
13 |
-
|
14 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20 |
-
THE SOFTWARE.
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/composer/autoload_classmap.php
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// autoload_classmap.php @generated by Composer
|
4 |
-
|
5 |
-
$vendorDir = dirname(dirname(__FILE__));
|
6 |
-
$baseDir = dirname($vendorDir);
|
7 |
-
|
8 |
-
return array(
|
9 |
-
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/composer/autoload_namespaces.php
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// autoload_namespaces.php @generated by Composer
|
4 |
-
|
5 |
-
$vendorDir = dirname(dirname(__FILE__));
|
6 |
-
$baseDir = dirname($vendorDir);
|
7 |
-
|
8 |
-
return array(
|
9 |
-
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/composer/autoload_psr4.php
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// autoload_psr4.php @generated by Composer
|
4 |
-
|
5 |
-
$vendorDir = dirname(dirname(__FILE__));
|
6 |
-
$baseDir = dirname($vendorDir);
|
7 |
-
|
8 |
-
return array(
|
9 |
-
'Automattic\\WooCommerce\\' => array($vendorDir . '/automattic/woocommerce/src/WooCommerce'),
|
10 |
-
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/composer/autoload_real.php
DELETED
@@ -1,52 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// autoload_real.php @generated by Composer
|
4 |
-
|
5 |
-
class ComposerAutoloaderInit61649fac88544a173986d28a0bc0bc23
|
6 |
-
{
|
7 |
-
private static $loader;
|
8 |
-
|
9 |
-
public static function loadClassLoader($class)
|
10 |
-
{
|
11 |
-
if ('Composer\Autoload\ClassLoader' === $class) {
|
12 |
-
require __DIR__ . '/ClassLoader.php';
|
13 |
-
}
|
14 |
-
}
|
15 |
-
|
16 |
-
public static function getLoader()
|
17 |
-
{
|
18 |
-
if (null !== self::$loader) {
|
19 |
-
return self::$loader;
|
20 |
-
}
|
21 |
-
|
22 |
-
spl_autoload_register(array('ComposerAutoloaderInit61649fac88544a173986d28a0bc0bc23', 'loadClassLoader'), true, true);
|
23 |
-
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('ComposerAutoloaderInit61649fac88544a173986d28a0bc0bc23', 'loadClassLoader'));
|
25 |
-
|
26 |
-
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
-
if ($useStaticLoader) {
|
28 |
-
require_once __DIR__ . '/autoload_static.php';
|
29 |
-
|
30 |
-
call_user_func(\Composer\Autoload\ComposerStaticInit61649fac88544a173986d28a0bc0bc23::getInitializer($loader));
|
31 |
-
} else {
|
32 |
-
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
-
foreach ($map as $namespace => $path) {
|
34 |
-
$loader->set($namespace, $path);
|
35 |
-
}
|
36 |
-
|
37 |
-
$map = require __DIR__ . '/autoload_psr4.php';
|
38 |
-
foreach ($map as $namespace => $path) {
|
39 |
-
$loader->setPsr4($namespace, $path);
|
40 |
-
}
|
41 |
-
|
42 |
-
$classMap = require __DIR__ . '/autoload_classmap.php';
|
43 |
-
if ($classMap) {
|
44 |
-
$loader->addClassMap($classMap);
|
45 |
-
}
|
46 |
-
}
|
47 |
-
|
48 |
-
$loader->register(true);
|
49 |
-
|
50 |
-
return $loader;
|
51 |
-
}
|
52 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/composer/autoload_static.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// autoload_static.php @generated by Composer
|
4 |
-
|
5 |
-
namespace Composer\Autoload;
|
6 |
-
|
7 |
-
class ComposerStaticInit61649fac88544a173986d28a0bc0bc23
|
8 |
-
{
|
9 |
-
public static $prefixLengthsPsr4 = array (
|
10 |
-
'A' =>
|
11 |
-
array (
|
12 |
-
'Automattic\\WooCommerce\\' => 23,
|
13 |
-
),
|
14 |
-
);
|
15 |
-
|
16 |
-
public static $prefixDirsPsr4 = array (
|
17 |
-
'Automattic\\WooCommerce\\' =>
|
18 |
-
array (
|
19 |
-
0 => __DIR__ . '/..' . '/automattic/woocommerce/src/WooCommerce',
|
20 |
-
),
|
21 |
-
);
|
22 |
-
|
23 |
-
public static function getInitializer(ClassLoader $loader)
|
24 |
-
{
|
25 |
-
return \Closure::bind(function () use ($loader) {
|
26 |
-
$loader->prefixLengthsPsr4 = ComposerStaticInit61649fac88544a173986d28a0bc0bc23::$prefixLengthsPsr4;
|
27 |
-
$loader->prefixDirsPsr4 = ComposerStaticInit61649fac88544a173986d28a0bc0bc23::$prefixDirsPsr4;
|
28 |
-
|
29 |
-
}, null, ClassLoader::class);
|
30 |
-
}
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/composer/installed.json
DELETED
@@ -1,52 +0,0 @@
|
|
1 |
-
[
|
2 |
-
{
|
3 |
-
"name": "automattic/woocommerce",
|
4 |
-
"version": "3.0.0",
|
5 |
-
"version_normalized": "3.0.0.0",
|
6 |
-
"source": {
|
7 |
-
"type": "git",
|
8 |
-
"url": "https://github.com/woocommerce/wc-api-php.git",
|
9 |
-
"reference": "a71aa95cc3de3f1d68c6303525d03c0557a96137"
|
10 |
-
},
|
11 |
-
"dist": {
|
12 |
-
"type": "zip",
|
13 |
-
"url": "https://api.github.com/repos/woocommerce/wc-api-php/zipball/a71aa95cc3de3f1d68c6303525d03c0557a96137",
|
14 |
-
"reference": "a71aa95cc3de3f1d68c6303525d03c0557a96137",
|
15 |
-
"shasum": ""
|
16 |
-
},
|
17 |
-
"require": {
|
18 |
-
"ext-curl": "*",
|
19 |
-
"ext-json": "*",
|
20 |
-
"php": ">= 5.4.0"
|
21 |
-
},
|
22 |
-
"require-dev": {
|
23 |
-
"phpunit/phpunit": "*",
|
24 |
-
"squizlabs/php_codesniffer": "3.*"
|
25 |
-
},
|
26 |
-
"time": "2019-01-16T20:28:40+00:00",
|
27 |
-
"type": "library",
|
28 |
-
"installation-source": "dist",
|
29 |
-
"autoload": {
|
30 |
-
"psr-4": {
|
31 |
-
"Automattic\\WooCommerce\\": [
|
32 |
-
"src/WooCommerce"
|
33 |
-
]
|
34 |
-
}
|
35 |
-
},
|
36 |
-
"notification-url": "https://packagist.org/downloads/",
|
37 |
-
"license": [
|
38 |
-
"MIT"
|
39 |
-
],
|
40 |
-
"authors": [
|
41 |
-
{
|
42 |
-
"name": "Claudio Sanches",
|
43 |
-
"email": "claudio.sanches@automattic.com"
|
44 |
-
}
|
45 |
-
],
|
46 |
-
"description": "A PHP wrapper for the WooCommerce REST API",
|
47 |
-
"keywords": [
|
48 |
-
"api",
|
49 |
-
"woocommerce"
|
50 |
-
]
|
51 |
-
}
|
52 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
woocommerce-stock-manager.php
CHANGED
@@ -3,44 +3,52 @@
|
|
3 |
* Plugin Name: Stock Manager for WooCommerce
|
4 |
* Plugin URI: https://www.storeapps.org/woocommerce-plugins/
|
5 |
* Description: Manage product's stock and price in your WooCommerce store. Export/Import inventory, track history, sort and more...
|
6 |
-
* Version: 2.
|
7 |
* Author: StoreApps
|
8 |
* Author URI: https://www.storeapps.org/
|
|
|
|
|
9 |
* Requires at least: 5.0.0
|
10 |
-
* Tested up to: 5.8.
|
11 |
* Requires PHP: 5.6+
|
12 |
* WC requires at least: 3.5.0
|
13 |
* WC tested up to: 5.6.0
|
14 |
* Text Domain: woocommerce-stock-manager
|
15 |
* Domain Path: /languages/
|
16 |
-
* Copyright (c) 2020-2021 StoreApps. All rights reserved.
|
17 |
* License: GNU General Public License v3.0
|
18 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
|
|
|
|
|
|
19 |
*/
|
20 |
|
|
|
|
|
|
|
|
|
21 |
// If this file is called directly, abort.
|
22 |
if ( ! defined( 'WPINC' ) ) {
|
23 |
die;
|
24 |
}
|
25 |
|
26 |
-
|
27 |
-
define( '
|
28 |
-
|
|
|
|
|
|
|
|
|
29 |
define( 'WSM_PLUGIN_FILE', __FILE__ );
|
30 |
}
|
31 |
-
if( !defined( 'WSM_PLUGIN_VERSION' ) ) {
|
32 |
define( 'WSM_PLUGIN_VERSION', get_woocommerce_stock_manager_plugin_version() );
|
33 |
}
|
34 |
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
* Public-Facing Functionality
|
39 |
-
*----------------------------------------------------------------------------*/
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
require_once( plugin_dir_path( __FILE__ ) . 'public/class-stock-manager.php' );
|
44 |
|
45 |
register_activation_hook( __FILE__, array( 'Stock_Manager', 'activate' ) );
|
46 |
register_deactivation_hook( __FILE__, array( 'Stock_Manager', 'deactivate' ) );
|
@@ -48,16 +56,24 @@ register_deactivation_hook( __FILE__, array( 'Stock_Manager', 'deactivate' ) );
|
|
48 |
add_action( 'plugins_loaded', array( 'Stock_Manager', 'get_instance' ) );
|
49 |
|
50 |
if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
|
51 |
-
require_once
|
52 |
add_action( 'plugins_loaded', array( 'Stock_Manager_Admin', 'get_instance' ) );
|
53 |
}
|
54 |
|
55 |
add_action( 'in_plugin_update_message-woocommerce-stock-manager/woocommerce-stock-manager.php', 'stockmanager_update_message_cb', 10, 2 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
function stockmanager_update_message_cb( $plugin_data, $r ) {
|
57 |
if ( version_compare( WSM_PLUGIN_VERSION, '2.0.0', '<' ) ) {
|
58 |
?>
|
59 |
<div class="wc_plugin_upgrade_notice extensions_warning minor">
|
60 |
-
<p><strong><?php
|
61 |
<table class="plugin-details-table" cellspacing="0">
|
62 |
<tbody>
|
63 |
<tr>
|
@@ -70,249 +86,280 @@ function stockmanager_update_message_cb( $plugin_data, $r ) {
|
|
70 |
</tr>
|
71 |
</tbody>
|
72 |
</table>
|
73 |
-
<p><?php
|
74 |
</div>
|
75 |
<?php
|
76 |
}
|
77 |
}
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
function wsm_search_by_title_only( $search, &$wp_query ) {
|
80 |
global $wpdb;
|
81 |
-
if ( empty( $search ) )
|
82 |
-
return $search; // skip processing - no search term in query
|
83 |
-
|
84 |
-
$
|
85 |
-
$
|
|
|
86 |
$searchand = '';
|
87 |
foreach ( (array) $q['search_terms'] as $term ) {
|
88 |
-
$term
|
89 |
-
$search
|
90 |
$searchand = ' AND ';
|
91 |
}
|
92 |
if ( ! empty( $search ) ) {
|
93 |
$search = " AND ({$search}) ";
|
94 |
-
if ( ! is_user_logged_in() )
|
95 |
$search .= " AND ($wpdb->posts.post_password = '') ";
|
|
|
96 |
}
|
97 |
return $search;
|
98 |
}
|
99 |
|
|
|
100 |
/**
|
101 |
-
* Get products for export
|
102 |
*/
|
103 |
-
add_action( 'wp_ajax_wsm_get_products_or_export', 'wsm_get_products_or_export' );
|
104 |
function wsm_get_products_or_export() {
|
105 |
|
106 |
check_ajax_referer( 'sa-wsm-export', 'security' );
|
107 |
|
108 |
-
$offset
|
109 |
-
$posts_per_page = 10;
|
110 |
-
$args
|
111 |
'post_type' => 'product',
|
112 |
'posts_status' => 'publish',
|
113 |
'posts_per_page' => $posts_per_page,
|
114 |
-
'offset' => $
|
115 |
);
|
116 |
-
$_products
|
117 |
-
if( !empty( $_products->posts ) ){
|
118 |
$data = array();
|
119 |
-
$i
|
120 |
-
foreach( $_products->posts as $item ){
|
121 |
-
|
122 |
-
$index = $item->ID;
|
123 |
$product = wc_get_product( $item->ID );
|
124 |
-
if( !
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
$product_name = $item->post_title;
|
126 |
-
if( !empty( $product->get_manage_stock() ) )
|
127 |
-
|
128 |
-
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
$product_type = $product->get_type();
|
131 |
|
132 |
-
$data[$index]['id'] = $item->ID;
|
133 |
-
$data[$index]['sku'] = $sku;
|
134 |
-
$data[$index]['product_name'] = $product_name;
|
135 |
-
$data[$index]['manage_stock'] = $manage_stock;
|
136 |
-
$data[$index]['stock_status'] = $stock_status;
|
137 |
-
$data[$index]['backorders'] = $backorders;
|
138 |
-
$data[$index]['stock'] = $stock;
|
139 |
-
$data[$index]['type'] = $product_type;
|
140 |
-
$data[$index]['parent_id'] = '';
|
141 |
-
|
142 |
-
$i++;
|
143 |
|
144 |
-
|
145 |
|
146 |
-
|
|
|
147 |
'post_parent' => $item->ID,
|
148 |
-
'post_type' => 'product_variation',
|
149 |
'numberposts' => -1,
|
150 |
-
'post_status' => 'publish'
|
151 |
-
);
|
152 |
$variations_array = get_children( $args );
|
153 |
-
foreach($variations_array as $vars){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
-
$
|
156 |
-
$item_product = wc_get_product($vars->ID);
|
157 |
-
if( !empty( $item_product->get_sku() ) ){ $sku = $item_product->get_sku(); }else{ $sku = ''; }
|
158 |
-
|
159 |
-
$product_name = '';
|
160 |
$item_product_attributes = wc_get_product_variation_attributes( $vindex );
|
161 |
-
foreach($item_product_attributes as $k => $v){
|
162 |
-
$tag = get_term_by('slug', $v, str_replace('attribute_',''
|
163 |
-
if($tag
|
164 |
-
$product_name .= $v.' ';
|
165 |
-
}else{
|
166 |
-
if(is_array($tag)){
|
167 |
-
$product_name .= $tag['name'].' ';
|
168 |
-
}else{
|
169 |
-
$product_name .= $tag->name.' ';
|
170 |
}
|
171 |
}
|
172 |
}
|
173 |
|
174 |
-
if( !empty( $item_product->get_manage_stock() ) )
|
175 |
-
|
176 |
-
|
177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
$product_type = 'product-variant';
|
179 |
|
180 |
-
$data[$vindex]['id'] = $vars->ID;
|
181 |
-
$data[$vindex]['sku'] = $sku;
|
182 |
-
$data[$vindex]['product_name'] = $product_name;
|
183 |
-
$data[$vindex]['manage_stock'] = $manage_stock;
|
184 |
-
$data[$vindex]['stock_status'] = $stock_status;
|
185 |
-
$data[$vindex]['backorders'] = $backorders;
|
186 |
-
$data[$vindex]['stock'] = $stock;
|
187 |
-
$data[$vindex]['type'] = $product_type;
|
188 |
-
$data[$vindex]['parent_id'] = $item->ID;
|
189 |
-
|
190 |
-
$i++;
|
191 |
|
|
|
192 |
}
|
193 |
}
|
194 |
-
|
195 |
}
|
196 |
-
$
|
197 |
-
$
|
198 |
-
'status'
|
199 |
-
'data'
|
200 |
-
'offset'
|
201 |
);
|
202 |
-
echo
|
203 |
exit();
|
204 |
} else {
|
205 |
-
$
|
206 |
-
'status'
|
207 |
-
'text'
|
208 |
);
|
209 |
-
echo
|
210 |
exit();
|
211 |
}
|
212 |
|
213 |
}
|
214 |
|
215 |
-
add_action( 'wp_ajax_wsm_get_csv_file', 'wsm_get_csv_file' );
|
216 |
-
|
|
|
|
|
|
|
217 |
|
218 |
check_ajax_referer( 'sa-wsm-get-csv', 'security' );
|
219 |
|
220 |
-
$data =
|
221 |
-
$data = (array)json_decode( $data );
|
222 |
|
223 |
$string = array();
|
224 |
-
foreach ($data as $line) {
|
225 |
|
226 |
$line_array = array(
|
227 |
-
'Id'
|
228 |
-
'Sku'
|
229 |
'Product name' => $line->product_name,
|
230 |
'Manage stock' => $line->manage_stock,
|
231 |
'Stock status' => $line->stock_status,
|
232 |
-
'Backorders'
|
233 |
-
'Stock'
|
234 |
-
'Type'
|
235 |
-
'Parent ID'
|
236 |
);
|
237 |
-
$string[]
|
238 |
}
|
239 |
|
240 |
-
echo
|
241 |
-
|
242 |
-
exit();
|
243 |
-
|
244 |
-
}
|
245 |
|
246 |
-
/**
|
247 |
-
* Get product data
|
248 |
-
*
|
249 |
-
*/
|
250 |
-
add_action( 'wp_ajax_wsm_get_product_data', 'wsm_get_product_data' );
|
251 |
-
function wsm_get_product_data(){
|
252 |
-
|
253 |
-
$product_id = sanitize_text_field( $_POST['productid'] );
|
254 |
-
$product = wc_get_product( $product_id );
|
255 |
-
|
256 |
-
$data = array();
|
257 |
-
$data['productid'] = $product_id;
|
258 |
-
|
259 |
-
if( !empty( $product->get_manage_stock() ) ){ $data['manage_stock'] = $product->get_manage_stock(); }
|
260 |
-
if( !empty( $product->get_stock_status() ) ){ $data['stock_status'] = $product->get_stock_status(); }
|
261 |
-
if( !empty( $product->get_backorders() ) ){ $data['backorders'] = $product->get_backorders(); }
|
262 |
-
if( !empty( $product->get_stock_quantity() ) ){ $data['stock'] = $product->get_stock_quantity(); }
|
263 |
-
|
264 |
-
echo json_encode( $data );
|
265 |
exit();
|
266 |
|
267 |
}
|
268 |
|
269 |
-
// for Klawoo subscribe.
|
270 |
add_action( 'wp_ajax_wsm_klawoo_subscribe', 'wsm_klawoo_subscribe' );
|
|
|
|
|
|
|
271 |
function wsm_klawoo_subscribe() {
|
272 |
$url = 'http://app.klawoo.com/subscribe';
|
273 |
-
if( !empty( $_POST ) ) {
|
274 |
-
$params = $_POST['params'];
|
275 |
} else {
|
276 |
exit();
|
277 |
}
|
278 |
|
279 |
-
$post_sa_wsm_nonce = (
|
280 |
if ( ! empty( $post_sa_wsm_nonce ) && wp_verify_nonce( $post_sa_wsm_nonce, 'sa-wsm-subscribe' ) ) {
|
281 |
-
if( empty($params['name']) ) {
|
282 |
$params['name'] = '';
|
283 |
}
|
284 |
|
285 |
$method = 'POST';
|
286 |
-
$qs
|
287 |
|
288 |
$options = array(
|
289 |
'timeout' => 15,
|
290 |
-
'method'
|
291 |
);
|
292 |
|
293 |
-
if (
|
294 |
$options['body'] = $qs;
|
295 |
} else {
|
296 |
if ( strpos( $url, '?' ) !== false ) {
|
297 |
-
$url .= '&'
|
298 |
} else {
|
299 |
-
$url .= '?'
|
300 |
}
|
301 |
}
|
302 |
|
303 |
$response = wp_remote_request( $url, $options );
|
304 |
-
if ( wp_remote_retrieve_response_code( $response )
|
305 |
$data = $response['body'];
|
306 |
|
307 |
-
if (
|
308 |
-
$message_start = substr( $data, strpos( $data,'<body>' ) + 6 );
|
309 |
-
$remove
|
310 |
-
$message
|
311 |
|
312 |
// Hide the in-app lead notice.
|
313 |
update_option( 'wsm_dismiss_subscribe_admin_notice', true, 'no' );
|
314 |
|
315 |
-
echo ( $message );
|
316 |
exit();
|
317 |
}
|
318 |
}
|
@@ -327,7 +374,7 @@ function wsm_klawoo_subscribe() {
|
|
327 |
* @since 2.7.0
|
328 |
*/
|
329 |
function get_woocommerce_stock_manager_plugin_data() {
|
330 |
-
if( ! function_exists( 'get_plugin_data' ) ) {
|
331 |
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
332 |
}
|
333 |
return get_plugin_data( WSM_PLUGIN_FILE );
|
3 |
* Plugin Name: Stock Manager for WooCommerce
|
4 |
* Plugin URI: https://www.storeapps.org/woocommerce-plugins/
|
5 |
* Description: Manage product's stock and price in your WooCommerce store. Export/Import inventory, track history, sort and more...
|
6 |
+
* Version: 2.8.0
|
7 |
* Author: StoreApps
|
8 |
* Author URI: https://www.storeapps.org/
|
9 |
+
* Developer: StoreApps
|
10 |
+
* Developer URI: https://www.storeapps.org/
|
11 |
* Requires at least: 5.0.0
|
12 |
+
* Tested up to: 5.8.1
|
13 |
* Requires PHP: 5.6+
|
14 |
* WC requires at least: 3.5.0
|
15 |
* WC tested up to: 5.6.0
|
16 |
* Text Domain: woocommerce-stock-manager
|
17 |
* Domain Path: /languages/
|
|
|
18 |
* License: GNU General Public License v3.0
|
19 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
20 |
+
* Copyright (c) 2020-2021 StoreApps. All rights reserved.
|
21 |
+
*
|
22 |
+
* @package woocommerce-stock-manager
|
23 |
*/
|
24 |
|
25 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
26 |
+
exit;
|
27 |
+
}
|
28 |
+
|
29 |
// If this file is called directly, abort.
|
30 |
if ( ! defined( 'WPINC' ) ) {
|
31 |
die;
|
32 |
}
|
33 |
|
34 |
+
if ( ! defined( 'STOCKDIR' ) ) {
|
35 |
+
define( 'STOCKDIR', plugin_dir_path( __FILE__ ) );
|
36 |
+
}
|
37 |
+
if ( ! defined( 'STOCKURL' ) ) {
|
38 |
+
define( 'STOCKURL', plugin_dir_url( __FILE__ ) );
|
39 |
+
}
|
40 |
+
if ( ! defined( 'WSM_PLUGIN_FILE' ) ) {
|
41 |
define( 'WSM_PLUGIN_FILE', __FILE__ );
|
42 |
}
|
43 |
+
if ( ! defined( 'WSM_PLUGIN_VERSION' ) ) {
|
44 |
define( 'WSM_PLUGIN_VERSION', get_woocommerce_stock_manager_plugin_version() );
|
45 |
}
|
46 |
|
47 |
+
// Public-Facing Functionality.
|
48 |
|
49 |
+
require_once plugin_dir_path( __FILE__ ) . 'admin/includes/class-wsm-save.php';
|
|
|
|
|
50 |
|
51 |
+
require_once plugin_dir_path( __FILE__ ) . 'public/class-stock-manager.php';
|
|
|
|
|
52 |
|
53 |
register_activation_hook( __FILE__, array( 'Stock_Manager', 'activate' ) );
|
54 |
register_deactivation_hook( __FILE__, array( 'Stock_Manager', 'deactivate' ) );
|
56 |
add_action( 'plugins_loaded', array( 'Stock_Manager', 'get_instance' ) );
|
57 |
|
58 |
if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
|
59 |
+
require_once plugin_dir_path( __FILE__ ) . 'admin/class-stock-manager-admin.php';
|
60 |
add_action( 'plugins_loaded', array( 'Stock_Manager_Admin', 'get_instance' ) );
|
61 |
}
|
62 |
|
63 |
add_action( 'in_plugin_update_message-woocommerce-stock-manager/woocommerce-stock-manager.php', 'stockmanager_update_message_cb', 10, 2 );
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Function to check if minimum WP & WC is satisfied before updating the plugin
|
67 |
+
* Shown on plugins page
|
68 |
+
*
|
69 |
+
* @param array $plugin_data Details about current plugin version + new update with plugin assets.
|
70 |
+
* @param object $r Details about new plugin version with plugin assets.
|
71 |
+
*/
|
72 |
function stockmanager_update_message_cb( $plugin_data, $r ) {
|
73 |
if ( version_compare( WSM_PLUGIN_VERSION, '2.0.0', '<' ) ) {
|
74 |
?>
|
75 |
<div class="wc_plugin_upgrade_notice extensions_warning minor">
|
76 |
+
<p><strong><?php esc_html_e( 'Alert!', 'woocommerce-stock-manager' ); ?></strong> <?php esc_html_e( 'Stock Manager for WooCommerce needs following versions of WordPress and WooCommerce:', 'woocommerce-stock-manager' ); ?></p>
|
77 |
<table class="plugin-details-table" cellspacing="0">
|
78 |
<tbody>
|
79 |
<tr>
|
86 |
</tr>
|
87 |
</tbody>
|
88 |
</table>
|
89 |
+
<p><?php esc_html_e( 'Please update WordPress and WooCommerce to the above versions before updating Stock Manager for WooCommerce.', 'woocommerce-stock-manager' ); ?></p>
|
90 |
</div>
|
91 |
<?php
|
92 |
}
|
93 |
}
|
94 |
|
95 |
+
/**
|
96 |
+
* Function to search a product by title
|
97 |
+
*
|
98 |
+
* @param string $search The term to search.
|
99 |
+
* @param object $wp_query The WP query object.
|
100 |
+
*/
|
101 |
function wsm_search_by_title_only( $search, &$wp_query ) {
|
102 |
global $wpdb;
|
103 |
+
if ( empty( $search ) ) {
|
104 |
+
return $search; // skip processing - no search term in query.
|
105 |
+
}
|
106 |
+
$q = $wp_query->query_vars;
|
107 |
+
$n = ! empty( $q['exact'] ) ? '' : '%';
|
108 |
+
$search = '';
|
109 |
$searchand = '';
|
110 |
foreach ( (array) $q['search_terms'] as $term ) {
|
111 |
+
$term = esc_sql( $wpdb->esc_like( $term ) );
|
112 |
+
$search .= "{$searchand}($wpdb->posts.post_title LIKE '{$n}{$term}{$n}')";
|
113 |
$searchand = ' AND ';
|
114 |
}
|
115 |
if ( ! empty( $search ) ) {
|
116 |
$search = " AND ({$search}) ";
|
117 |
+
if ( ! is_user_logged_in() ) {
|
118 |
$search .= " AND ($wpdb->posts.post_password = '') ";
|
119 |
+
}
|
120 |
}
|
121 |
return $search;
|
122 |
}
|
123 |
|
124 |
+
add_action( 'wp_ajax_wsm_get_products_or_export', 'wsm_get_products_or_export' );
|
125 |
/**
|
126 |
+
* Get products for export.
|
127 |
*/
|
|
|
128 |
function wsm_get_products_or_export() {
|
129 |
|
130 |
check_ajax_referer( 'sa-wsm-export', 'security' );
|
131 |
|
132 |
+
$passed_offset = ( ! empty( $_POST['offset'] ) ) ? intval( wc_clean( wp_unslash( $_POST['offset'] ) ) ) : 0; // phpcs:ignore
|
133 |
+
$posts_per_page = 10; // TODO: would need to increase and handle logic to get all products in export.
|
134 |
+
$args = array(
|
135 |
'post_type' => 'product',
|
136 |
'posts_status' => 'publish',
|
137 |
'posts_per_page' => $posts_per_page,
|
138 |
+
'offset' => $passed_offset,
|
139 |
);
|
140 |
+
$_products = new WP_Query( $args );
|
141 |
+
if ( ! empty( $_products->posts ) ) {
|
142 |
$data = array();
|
143 |
+
$i = 1 + $passed_offset;
|
144 |
+
foreach ( $_products->posts as $item ) {
|
145 |
+
$index = $item->ID;
|
|
|
146 |
$product = wc_get_product( $item->ID );
|
147 |
+
if ( ! $product instanceof WC_Product ) {
|
148 |
+
continue;
|
149 |
+
}
|
150 |
+
if ( ! empty( $product->get_sku() ) ) {
|
151 |
+
$sku = $product->get_sku();
|
152 |
+
} else {
|
153 |
+
$sku = '';
|
154 |
+
}
|
155 |
$product_name = $item->post_title;
|
156 |
+
if ( ! empty( $product->get_manage_stock() ) ) {
|
157 |
+
$manage_stock = $product->get_manage_stock();
|
158 |
+
} else {
|
159 |
+
$manage_stock = '';
|
160 |
+
}
|
161 |
+
if ( ! empty( $product->get_stock_status() ) ) {
|
162 |
+
$stock_status = $product->get_stock_status();
|
163 |
+
} else {
|
164 |
+
$stock_status = '';
|
165 |
+
}
|
166 |
+
if ( ! empty( $product->get_backorders() ) ) {
|
167 |
+
$backorders = $product->get_backorders();
|
168 |
+
} else {
|
169 |
+
$backorders = '';
|
170 |
+
}
|
171 |
+
if ( ! empty( $product->get_stock_quantity() ) ) {
|
172 |
+
$stock = $product->get_stock_quantity();
|
173 |
+
} else {
|
174 |
+
$stock = '';
|
175 |
+
}
|
176 |
$product_type = $product->get_type();
|
177 |
|
178 |
+
$data[ $index ]['id'] = $item->ID;
|
179 |
+
$data[ $index ]['sku'] = $sku;
|
180 |
+
$data[ $index ]['product_name'] = $product_name;
|
181 |
+
$data[ $index ]['manage_stock'] = $manage_stock;
|
182 |
+
$data[ $index ]['stock_status'] = $stock_status;
|
183 |
+
$data[ $index ]['backorders'] = $backorders;
|
184 |
+
$data[ $index ]['stock'] = $stock;
|
185 |
+
$data[ $index ]['type'] = $product_type;
|
186 |
+
$data[ $index ]['parent_id'] = '';
|
|
|
|
|
187 |
|
188 |
+
$i++;
|
189 |
|
190 |
+
if ( 'variable' === $product_type ) {
|
191 |
+
$args = array(
|
192 |
'post_parent' => $item->ID,
|
193 |
+
'post_type' => 'product_variation',
|
194 |
'numberposts' => -1,
|
195 |
+
'post_status' => 'publish',
|
196 |
+
);
|
197 |
$variations_array = get_children( $args );
|
198 |
+
foreach ( $variations_array as $vars ) {
|
199 |
+
$vindex = $vars->ID;
|
200 |
+
$item_product = wc_get_product( $vars->ID );
|
201 |
+
if ( ! $item_product instanceof WC_Product ) {
|
202 |
+
continue;
|
203 |
+
}
|
204 |
+
if ( ! empty( $item_product->get_sku() ) ) {
|
205 |
+
$sku = $item_product->get_sku();
|
206 |
+
} else {
|
207 |
+
$sku = '';
|
208 |
+
}
|
209 |
|
210 |
+
$product_name = '';
|
|
|
|
|
|
|
|
|
211 |
$item_product_attributes = wc_get_product_variation_attributes( $vindex );
|
212 |
+
foreach ( $item_product_attributes as $k => $v ) {
|
213 |
+
$tag = get_term_by( 'slug', $v, str_replace( 'attribute_', '', $k ) );
|
214 |
+
if ( false === $tag ) {
|
215 |
+
$product_name .= $v . ' ';
|
216 |
+
} else {
|
217 |
+
if ( is_array( $tag ) ) {
|
218 |
+
$product_name .= $tag['name'] . ' ';
|
219 |
+
} else {
|
220 |
+
$product_name .= $tag->name . ' ';
|
221 |
}
|
222 |
}
|
223 |
}
|
224 |
|
225 |
+
if ( ! empty( $item_product->get_manage_stock() ) ) {
|
226 |
+
$manage_stock = $item_product->get_manage_stock();
|
227 |
+
} else {
|
228 |
+
$manage_stock = '';
|
229 |
+
}
|
230 |
+
if ( ! empty( $item_product->get_stock_status() ) ) {
|
231 |
+
$stock_status = $item_product->get_stock_status();
|
232 |
+
} else {
|
233 |
+
$stock_status = '';
|
234 |
+
}
|
235 |
+
if ( ! empty( $item_product->get_backorders() ) ) {
|
236 |
+
$backorders = $item_product->get_backorders();
|
237 |
+
} else {
|
238 |
+
$backorders = '';
|
239 |
+
}
|
240 |
+
if ( ! empty( $item_product->get_stock_quantity() ) ) {
|
241 |
+
$stock = $item_product->get_stock_quantity();
|
242 |
+
} else {
|
243 |
+
$stock = '';
|
244 |
+
}
|
245 |
$product_type = 'product-variant';
|
246 |
|
247 |
+
$data[ $vindex ]['id'] = $vars->ID;
|
248 |
+
$data[ $vindex ]['sku'] = $sku;
|
249 |
+
$data[ $vindex ]['product_name'] = $product_name;
|
250 |
+
$data[ $vindex ]['manage_stock'] = $manage_stock;
|
251 |
+
$data[ $vindex ]['stock_status'] = $stock_status;
|
252 |
+
$data[ $vindex ]['backorders'] = $backorders;
|
253 |
+
$data[ $vindex ]['stock'] = $stock;
|
254 |
+
$data[ $vindex ]['type'] = $product_type;
|
255 |
+
$data[ $vindex ]['parent_id'] = $item->ID;
|
|
|
|
|
256 |
|
257 |
+
$i++;
|
258 |
}
|
259 |
}
|
|
|
260 |
}
|
261 |
+
$passed_offset = $passed_offset + 10;
|
262 |
+
$response = array(
|
263 |
+
'status' => 'continue',
|
264 |
+
'data' => $data,
|
265 |
+
'offset' => $passed_offset,
|
266 |
);
|
267 |
+
echo wp_json_encode( $response );
|
268 |
exit();
|
269 |
} else {
|
270 |
+
$response = array(
|
271 |
+
'status' => 'finish',
|
272 |
+
'text' => __( 'All done! Close.', 'woocommerce-stock-manager' ),
|
273 |
);
|
274 |
+
echo wp_json_encode( $response );
|
275 |
exit();
|
276 |
}
|
277 |
|
278 |
}
|
279 |
|
280 |
+
add_action( 'wp_ajax_wsm_get_csv_file', 'wsm_get_csv_file' );
|
281 |
+
/**
|
282 |
+
* Get CSV file for export.
|
283 |
+
*/
|
284 |
+
function wsm_get_csv_file() {
|
285 |
|
286 |
check_ajax_referer( 'sa-wsm-get-csv', 'security' );
|
287 |
|
288 |
+
$data = ( ! empty( $_POST['data'] ) ) ? wc_clean( wp_unslash( $_POST['data'] ) ) : array(); // phpcs:ignore
|
289 |
+
$data = (array) json_decode( $data );
|
290 |
|
291 |
$string = array();
|
292 |
+
foreach ( $data as $line ) {
|
293 |
|
294 |
$line_array = array(
|
295 |
+
'Id' => $line->id,
|
296 |
+
'Sku' => $line->sku,
|
297 |
'Product name' => $line->product_name,
|
298 |
'Manage stock' => $line->manage_stock,
|
299 |
'Stock status' => $line->stock_status,
|
300 |
+
'Backorders' => $line->backorders,
|
301 |
+
'Stock' => $line->stock,
|
302 |
+
'Type' => $line->type,
|
303 |
+
'Parent ID' => $line->parent_id,
|
304 |
);
|
305 |
+
$string[] = $line_array;
|
306 |
}
|
307 |
|
308 |
+
echo wp_json_encode( $string );
|
|
|
|
|
|
|
|
|
309 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
exit();
|
311 |
|
312 |
}
|
313 |
|
|
|
314 |
add_action( 'wp_ajax_wsm_klawoo_subscribe', 'wsm_klawoo_subscribe' );
|
315 |
+
/**
|
316 |
+
* Function for Klawoo subscribe.
|
317 |
+
*/
|
318 |
function wsm_klawoo_subscribe() {
|
319 |
$url = 'http://app.klawoo.com/subscribe';
|
320 |
+
if ( ! empty( $_POST ) ) {
|
321 |
+
$params = ( ! empty( $_POST['params'] ) ) ? wc_clean( wp_unslash( $_POST['params'] ) ) : array(); // phpcs:ignore
|
322 |
} else {
|
323 |
exit();
|
324 |
}
|
325 |
|
326 |
+
$post_sa_wsm_nonce = ( ! empty( $params['sa_wsm_sub_nonce'] ) ) ? wc_clean( wp_unslash( $params['sa_wsm_sub_nonce'] ) ) : '';
|
327 |
if ( ! empty( $post_sa_wsm_nonce ) && wp_verify_nonce( $post_sa_wsm_nonce, 'sa-wsm-subscribe' ) ) {
|
328 |
+
if ( empty( $params['name'] ) ) {
|
329 |
$params['name'] = '';
|
330 |
}
|
331 |
|
332 |
$method = 'POST';
|
333 |
+
$qs = http_build_query( $params );
|
334 |
|
335 |
$options = array(
|
336 |
'timeout' => 15,
|
337 |
+
'method' => $method,
|
338 |
);
|
339 |
|
340 |
+
if ( 'POST' === $method ) {
|
341 |
$options['body'] = $qs;
|
342 |
} else {
|
343 |
if ( strpos( $url, '?' ) !== false ) {
|
344 |
+
$url .= '&' . $qs;
|
345 |
} else {
|
346 |
+
$url .= '?' . $qs;
|
347 |
}
|
348 |
}
|
349 |
|
350 |
$response = wp_remote_request( $url, $options );
|
351 |
+
if ( 200 === wp_remote_retrieve_response_code( $response ) ) {
|
352 |
$data = $response['body'];
|
353 |
|
354 |
+
if ( 'error' !== $data ) {
|
355 |
+
$message_start = substr( $data, strpos( $data, '<body>' ) + 6 );
|
356 |
+
$remove = substr( $message_start, strpos( $message_start, '</body>' ) );
|
357 |
+
$message = trim( str_replace( $remove, '', $message_start ) );
|
358 |
|
359 |
// Hide the in-app lead notice.
|
360 |
update_option( 'wsm_dismiss_subscribe_admin_notice', true, 'no' );
|
361 |
|
362 |
+
echo wp_kses_post( $message );
|
363 |
exit();
|
364 |
}
|
365 |
}
|
374 |
* @since 2.7.0
|
375 |
*/
|
376 |
function get_woocommerce_stock_manager_plugin_data() {
|
377 |
+
if ( ! function_exists( 'get_plugin_data' ) ) {
|
378 |
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
379 |
}
|
380 |
return get_plugin_data( WSM_PLUGIN_FILE );
|