PluginProbe
MakeCommerce for WooCommerce / 2.6.2
MakeCommerce for WooCommerce v2.6.2
4.1.0 4.0.8 trunk 1.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.0 2.2.1 2.2.2 All 96 releases
makecommerce / trunk / makecommerce.php

makecommerce.php in MakeCommerce for WooCommerce 2.6.2, at trunk/makecommerce.php

567 lines 22.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: MakeCommerce for WooCommerce
4 Description: Adds MakeCommerce payment gateway and Itella/Omniva parcel machine shipping methods to Woocommerce checkout
5 Version: 2.6.2
6 Author: Maksekeskus AS
7 Author URI: https://MakeCommerce.net/
8 Text Domain: wc_makecommerce_domain
9 WC requires at least: 3.0
10 WC tested up to: 4.5.1
11 */
12
13 if (!defined('ABSPATH')) {
14 exit; // Exit if accessed directly.
15 }
16
17 include_once(ABSPATH.'wp-admin/includes/plugin.php');
18 if (is_plugin_active('woocommerce/woocommerce.php')) {
19
20 define('WC_MC_VERSION', 2.0);
21
22 $enable_experimental = get_option('mk_checkout_sco', 'no');
23 if ($enable_experimental === 'yes') {
24 require_once(__DIR__.'/makecommerce-simplecheckout.php');
25 }
26 require_once(__DIR__.'/makecommerce-transport.php');
27 require_once(__DIR__.'/makecommerce-payment.php');
28
29 if (is_admin() && !extension_loaded('curl')) {
30 add_action('admin_notices', function(){
31 $class = 'notice notice-error';
32 $message = __( 'You have enabled MakeCommerce module but it seems that you don\'t have CURL enabled. This way MakeCommerce unfortunately does not work!', 'wc_makecommerce_domain');
33 printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) );
34 });
35 }
36
37
38 global $mkDbTable;
39 $mkDbTable = 'mc_banklinks';
40
41 function mc_install() {
42 global $wpdb;
43 global $mkDbTable;
44
45 $tableName = $wpdb->prefix . $mkDbTable;
46
47 $charset = $wpdb->get_charset_collate();
48
49 $sql = "CREATE TABLE $tableName (
50 id mediumint(9) NOT NULL AUTO_INCREMENT,
51 type varchar(10) NOT NULL,
52 country char(2) NOT NULL,
53 name varchar(25) NOT NULL,
54 url varchar(250) NOT NULL,
55 logo_url varchar(250),
56 min_amount mediumint(9),
57 max_amount mediumint(9),
58 UNIQUE KEY id (id)
59 ) $charset;";
60
61 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
62 dbDelta( $sql );
63 }
64
65 register_activation_hook( __FILE__, 'mc_install' );
66
67 // On uninstall remove scheduled hook
68 function mc_uninstall() {
69 if (wp_next_scheduled ( 'mc_banklinks_update_cron' )) {
70 wp_clear_scheduled_hook('mc_banklinks_update_cron');
71 }
72 }
73
74 register_deactivation_hook(__FILE__, 'mc_uninstall');
75
76 // WP schedule callable action
77 add_action('mc_banklinks_update_cron', 'update_mc_banklinks');
78 // Assign schedule if not set, update compatible no need to reactivate, format('U') php 5.2 compatible
79 // Assigns task at 23.59.59 by local time, task runs if time has passed and somebody navigates the site
80 if (! wp_next_scheduled ( 'mc_banklinks_update_cron' )) {
81 $date = new DateTime();
82 $date->setTime(rand(0,23),rand(0,59),00);
83 $timestamp = intval($date->format('U'));
84 //$local = 3600 * intval(get_option('gmt_offset'));
85 //wp_schedule_event($timestamp - $local, 'twicedaily', 'mc_banklinks_update_cron');
86 wp_schedule_event($timestamp, 'twicedaily', 'mc_banklinks_update_cron');
87 }
88
89 if (!class_exists('wc_makecommerce_domain')) {
90 require_once('includes/vendor/autoload.php');
91 require_once('includes/Maksekeskus.php');
92 }
93
94 function mk_check_payment() {
95
96 global $woocommerce;
97 $api = mk_get_api();
98
99 //set the correct language
100 if (isset($_GET["lang1"])) {
101 //set polylang language
102 if (function_exists('pll_current_language')) {
103 //get the correct locale name from polylang
104 $polylangLangs = pll_the_languages(array('raw' => 1));
105 if (isset($polylangLangs[$_GET["lang1"]])) {
106 $locale = str_replace("-", "_", $polylangLangs[$_GET["lang1"]]["locale"]);
107 }
108
109 //first change WP language, this triggers some polylang hooks
110 switch_to_locale($locale);
111
112 //second, change WPML language?!?! this ensures the correct landingpage (works with polylang)
113 do_action('wpml_switch_language', $_GET["lang1"]);
114 } else {
115 if (function_exists('icl_object_id')) { //weirdly enough icl_object ID exists in this point of the request. It doesn't in other locations...
116 //set wpml language
117 do_action('wpml_switch_language', $_GET["lang1"]);
118 }
119 }
120 }
121
122 $returnUrl = home_url();
123
124 $request = stripslashes_deep($_POST);
125 if ($api->verifyMac($request)) {
126 $data = $api->extractRequestData($request);
127 $reference = false;
128
129 if (!empty($data['error']) ) {
130 wc_add_notice(__('Payment failed', 'wc_makecommerce_domain'), 'error');
131 return $returnUrl;
132 }
133
134 if (!empty($data['message_type']) ) {
135 if ($data['message_type'] == 'payment_return') {
136 $transactionId = $data['transaction'];
137 $reference = $data['reference'];
138 $paymentStatus = $data['status'];
139 }
140 if ($data['message_type'] == 'token_return') {
141 if (!empty($data['transaction']['reference'])) {
142 $reference = $data['transaction']['reference'];
143 }
144 $paymentStatus = $data['transaction']['status'];
145 $transactionId = $data['transaction']['id'];
146
147 // for API backward compatibility - if we didn't find reference in the mesage, or the transaction state vas still PENDING
148 // we'll fetch the transaction data from API, and make a payment request if needed
149 // this all can be removed after 2017-jan
150 if (!$reference or $paymentStatus == 'PENDING') {
151 $transaction = $api->getTransaction($transactionId);
152 if (!empty($transaction->reference)) {
153 $reference = $transaction->reference;
154 }
155
156 $paymentStatus = $transaction->status;
157
158 if ($paymentStatus == 'PENDING') {
159 $paymentRequest = array(
160 'amount' => (string)sprintf("%.2f", $transaction->amount),
161 'currency' => $transaction->currency,
162 'token' => $data['token']['id']
163 );
164 $payment = $api->createPayment($transactionId, $paymentRequest);
165 // TODO: validate
166 $paymentStatus = $payment->transaction->status;
167 }
168
169 }
170
171
172 }
173
174 }
175 }
176
177 // if we didn't find reference to an Order, we send user to shop landing-page. TODO: could be improved
178 if (!$reference) { return $returnUrl; }
179
180 $order = new WC_Order($reference);
181 // if we din't find the Order, we send user to shop landing-page. TODO: could be improved
182 if (!$order->get_id()) { return $returnUrl; }
183
184 $returnUrl = $order->get_checkout_order_received_url();
185
186 if ($paymentStatus == 'CANCELLED' || $paymentStatus == 'COMPLETED') {
187 //get transaction to update the payment method.
188 $transaction = $api->getTransaction($transactionId);
189
190 //make sure the payment method is the same for simplecheckout and normal version.
191 $paymentMethod = "";
192 if (isset($transaction->type) && isset($transaction->method)) {
193 $paymentMethod = $transaction->channel;
194 }
195
196 //update _makecommerce_preselected_method
197 update_post_meta($order->get_id(), '_makecommerce_preselected_method', $paymentMethod);
198 }
199
200 switch($paymentStatus) {
201
202 case 'CANCELLED':
203 $order->update_status( 'cancelled' );
204 wc_add_notice(__('Payment transaction cancelled', 'wc_makecommerce_domain'), 'error');
205 $returnUrl = wc_get_cart_url();
206 break;
207
208 case 'COMPLETED':
209 $orderNote = array();
210 $orderNote[] = __('Transaction ID', 'wc_makecommerce_domain') . ': <a target=_blank href="'.$api->getEnvUrls()->merchantUrl.'/merchant/shop/deals/detail.html?id='. $transactionId .'">'.$transactionId.'</a>';
211 $orderNote[] = __('Payment option', 'wc_makecommerce_domain') . ': ' . get_post_meta($order->get_id(), '_makecommerce_preselected_method', true);
212 $order->add_order_note(implode("\r\n", $orderNote));
213 if (!empty($data['token']) && !empty($data['token']['multiuse'])) {
214 update_post_meta($order->get_id(), '_makecommerce_payment_token', $data['token']['id']);
215 update_post_meta($order->get_id(), '_makecommerce_payment_token_valid_until', $data['token']['valid_until']);
216 }
217
218 if (isset($_GET['lang1'])) {
219 $order->update_meta_data('wpml_language', $_GET["lang1"]);
220 }
221
222 $order->payment_complete( $transactionId );
223 $woocommerce->cart->empty_cart();
224 break;
225 }
226
227 return $returnUrl;
228 }
229
230
231
232
233 $MKAPI = false;
234 function mk_get_api() {
235 global $MKAPI;
236 if ($MKAPI) {
237 //return $MKAPI;
238 }
239 $mk_api_type = get_option('mk_api_type', false);
240 if (!$mk_api_type) {
241 return false;
242 }
243 if ($mk_api_type !== 'live') {
244 $key_prefix = $mk_api_type.'_';
245 } else {
246 $key_prefix = '';
247 }
248 $mk_shop_id = get_option('mk_'.$key_prefix.'shop_id', '');
249 $mk_public_key = get_option('mk_'.$key_prefix.'public_key', '');
250 $mk_private_key = get_option('mk_'.$key_prefix.'private_key', '');
251 if (!$mk_shop_id || !$mk_public_key || !$mk_shop_id) {
252 return false;
253 }
254 $MKAPI = new \Maksekeskus\Maksekeskus($mk_shop_id, $mk_public_key, $mk_private_key, $mk_api_type === 'live' ? false : true);
255 return $MKAPI;
256 }
257
258 function mk_is_api_set() {
259 $mk_api_type = get_option('mk_api_type', false);
260 if (!$mk_api_type) {
261 return false;
262 }
263 if ($mk_api_type !== 'live') {
264 $key_prefix = $mk_api_type.'_';
265 } else {
266 $key_prefix = '';
267 }
268 $mk_shop_id = get_option('mk_'.$key_prefix.'shop_id', '');
269 $mk_public_key = get_option('mk_'.$key_prefix.'public_key', '');
270 $mk_private_key = get_option('mk_'.$key_prefix.'private_key', '');
271 if (!$mk_shop_id || !$mk_public_key || !$mk_shop_id) {
272 return false;
273 }
274 return true;
275 }
276
277
278 function mk_admin_error() {
279 printf( '<div class="%1$s"><p>%2$s</p></div>', 'notice notice-error', __('Please check that you have configured correctly MakeCommerce API accesses', 'wc_makecommerce_domain'));
280 }
281
282
283
284 add_filter('query_vars', 'mk_cron_query_vars');
285 add_action('parse_request', 'mk_parse_cron_update_vars');
286
287 function mk_cron_query_vars($vars) {
288 $vars[] = 'mk-action';
289 $vars[] = 'mk-shop-id';
290 $vars[] = 'mk-test-shop-id';
291 return $vars;
292 }
293
294 function mk_parse_cron_update_vars($wp) {
295 if (array_key_exists('mk-action', $wp->query_vars) && $wp->query_vars['mk-action'] == 'mk-update'
296 && (array_key_exists('mk-shop-id', $wp->query_vars) || array_key_exists('mk-test-shop-id', $wp->query_vars) ) ) {
297 if( (strlen($wp->query_vars['mk-shop-id']) && $wp->query_vars['mk-shop-id'] == get_option('mk_shop_id', false) )
298 || (strlen($wp->query_vars['mk-test-shop-id']) && $wp->query_vars['mk-test-shop-id'] == get_option('mk_test_shop_id', false) ) ) {
299 update_mc_banklinks();
300 exit();
301 }
302 }
303 }
304
305 function mk_admin_login_update($user_login, $user) {
306 if(user_can( $user, 'administrator' )) {
307 update_mc_banklinks();
308 }
309 }
310 add_action('wp_login', 'mk_admin_login_update', 10, 2);
311
312
313
314 function mk_admin_add_api_settings($sections) {
315 $sections['mk_api'] = __('MakeCommerce API access', 'wc_makecommerce_domain');
316 return $sections;
317 }
318
319 function mk_admin_api_settings($settings) {
320 global $current_section;
321 if ($current_section !== 'mk_api') {
322 return $settings;
323 }
324 return array(
325 array('type' => 'title', 'desc' => __get_logo_html()),
326 array(
327 'type' => 'title',
328 'title' => __('MakeCommerce API access credentials', 'wc_makecommerce_domain'),
329 'desc' => __('To use MakeCommerce/Maksekeskus services you need to enter API credentials below here <br/> <br/>', 'wc_makecommerce_domain').
330 sprintf( __('To further configure the Payment methods please go to <a href=."%s">MakeCommerce Checkout Options</a>, links to settings of our Shipment methods are listed below', 'wc_makecommerce_domain'), 'admin.php?page=wc-settings&tab=checkout&section=makecommerce'),
331 'id' => 'mk_api_settings'
332 ),
333 array(
334 'type' => 'select',
335 'title' => __('Current environment', 'wc_makecommerce_domain'),
336 'desc' => __('See more about <a href="https://maksekeskus.ee/en/for-developers/test-environment/">MakeCommerce Test environment</a>', 'wc_makecommerce_domain'),
337 'default' => 'live',
338 'options' => array(
339 'live' => __('Live', 'wc_makecommerce_domain'),
340 'test' => __('Test', 'wc_makecommerce_domain'),
341 ),
342 'id' => 'mk_api_type'
343 ),
344 array(
345 'id' => 'mk_shop_id',
346 'type' => 'text',
347 'title' => __('Shop ID (live)', 'wc_makecommerce_domain'),
348 'desc' => __('Get it from <a href="https://merchant.maksekeskus.ee/api.html" target="_blank">Merchant Portal</a>','wc_makecommerce_domain'),
349 'class' => 'input-text regular-input',
350 ),
351 array(
352 'id' => 'mk_private_key',
353 'type' => 'text',
354 'title' => __('Secret key (live)', 'wc_makecommerce_domain'),
355 'class' => 'input-text regular-input',
356 ),
357 array(
358 'id' => 'mk_public_key',
359 'type' => 'text',
360 'title' => __('Publishable key (live)', 'wc_makecommerce_domain'),
361 'class' => 'input-text regular-input',
362 ),
363 array(
364 'id' => 'mk_test_shop_id',
365 'type' => 'text',
366 'title' => __('Shop ID (test)', 'wc_makecommerce_domain'),
367 'class' => 'input-text regular-input',
368 'default' => 'f64b4f20-5ef9-4b7b-a6fa-d623d87f0b9c',
369 'desc' => __('Get it from <a href="https://merchant-test.maksekeskus.ee/api.html" target="_blank">Merchant Portal Test</a>','wc_makecommerce_domain'),
370 ),
371 array(
372 'id' => 'mk_test_private_key',
373 'type' => 'text',
374 'title' => __('Secret key (test)', 'wc_makecommerce_domain'),
375 'default' => 'MPjcVMoRZPAucsTuGK5ZukOlV7BlzgSvXOowJUkk9IFSQPVooRwcVOxzz3mhEpgM',
376 'class' => 'input-text regular-input',
377 ),
378 array(
379 'id' => 'mk_test_public_key',
380 'type' => 'text',
381 'title' => __('Publishable key (test)', 'wc_makecommerce_domain'),
382 'default' => '7Hog41ci2mKkmtviMycWxpNx14pNP70m',
383 'class' => 'input-text regular-input',
384 ),
385 array('type' => 'sectionend', 'id' => 'mk_api_settings'),
386 array(
387 'type' => 'title',
388 'desc' => '<br><hr><br>',
389 ),
390 array(
391 'id' => 'mk_module_title',
392 'type' => 'title',
393 'title' => __('Makecommerce modules', 'wc_makecommerce_domain'),
394 'desc' => __('Our plugin adds several modules to your shop. Here you can switch off modules that are not important for you, they will disappear from Woocommerce settings menus.<br> Each active module have their own settings dialog, where they must also be Enabled before use.', 'wc_makecommerce_domain'),
395 'class' => '',
396 ),
397 array(
398 'id' => 'mk_transport_apt_omniva',
399 'type' => 'checkbox',
400 'default' => 'yes',
401 'title' => __('Omniva Parcel Machine', 'wc_makecommerce_domain'),
402 'desc' => __('enable Omniva parcel machines shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping&section=parcelmachine_omniva')).')',
403 'class' => '',
404 ),
405 array(
406 'id' => 'mk_transport_apt_smartpost',
407 'type' => 'checkbox',
408 'default' => 'yes',
409 'title' => __('SmartPOST Parcel Machine', 'wc_makecommerce_domain'),
410 'desc' => __('enable SmartPOST parcel machines shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping&section=parcelmachine_smartpost')).')',
411 'class' => '',
412 ),
413 array(
414 'id' => 'mk_transport_apt_dpd',
415 'type' => 'checkbox',
416 'default' => 'no',
417 'title' => __('DPD', 'wc_makecommerce_domain') . ' ' . __('parcel machine', 'wc_makecommerce_domain'),
418 'desc' => __('enable DPD parcel machine shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping&section=parcelmachine_dpd')).')',
419 'class' => '',
420 ),
421 array(
422 'id' => 'mk_transport_courier_omniva',
423 'type' => 'checkbox',
424 'default' => 'yes',
425 'title' => __('Omniva Courier', 'wc_makecommerce_domain'),
426 'desc' => __('enable Omniva courier shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping&section=courier_omniva')).')',
427 'class' => '',
428 ),
429 array(
430 'id' => 'mk_transport_courier_smartpost',
431 'type' => 'checkbox',
432 'default' => 'yes',
433 'title' => __('SmartPOST Courier', 'wc_makecommerce_domain'),
434 'desc' => __('enable SmartPOST courier shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping&section=courier_smartpost')).')',
435 'class' => '',
436 ),
437 array(
438 'id' => 'mk_checkout_sco',
439 'type' => 'checkbox',
440 'title' => __('SimpleCheckout', 'wc_makecommerce_domain'),
441 'desc' => __('enable SimpleCheckout&trade; Checkout method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=checkout&section=makecommerce_sc')).')',
442 'class' => '',
443 ),
444 array(
445 'id' => 'mk_product_slice',
446 'type' => 'checkbox',
447 'title' => __('Indivy Slice 3 information in product view', 'wc_makecommerce_domain'),
448 'desc' => __('enable Indivy Slice 3 in product view', 'wc_makecommerce_domain'),
449 'class' => '',
450 ),
451 array(
452 'id' => 'mk_javascript_ui',
453 'type' => 'api_javascript_ui',
454 ),
455 array('type' => 'sectionend', 'id' => 'mk_api_settings')
456 );
457 }
458
459 function mk_wc_version($version) {
460 global $woocommerce;
461 if ( version_compare( $woocommerce->version, "3.4.0", ">=" ) ) {
462 return true;
463 } else {
464 return false;
465 }
466 }
467
468 function mk_admin_save_api_settings() {
469 // reload banklinks
470 global $current_section;
471 if ($current_section !== 'mk_api') {
472 return;
473 }
474 update_mc_banklinks();
475 }
476
477 function mk_admin_plugin_settings_link($links) {
478 if (mk_wc_version("3.4.0"))
479 $settings_link = '<a href="admin.php?page=wc-settings&tab=advanced&section=mk_api">API '.__('Settings').'</a>';
480 else
481 $settings_link = '<a href="admin.php?page=wc-settings&tab=api&section=mk_api">API '.__('Settings').'</a>';
482 array_unshift($links, $settings_link);
483 return $links;
484 }
485
486 function wc_mc_shop_slice_button() {
487 if (get_option('mk_product_slice', 'no') == 'yes') {
488 global $product;
489 // $price_excl_tax = wc_get_price_excluding_tax( $product ); // price without VAT
490 $price_incl_tax = wc_get_price_including_tax( $product ); // price with VAT
491 global $wpdb;
492 global $mkDbTable;
493 $tableName = $wpdb->prefix . $mkDbTable;
494 $methods = $wpdb->get_results('SELECT * FROM '.$tableName);
495 $slice = false;
496 if(count($methods)) {
497 foreach ($methods as $method) {
498 if ($method->name =="slice") {
499 if ( $price_incl_tax >= $method->min_amount ) {
500 if ( $price_incl_tax <= $method->max_amount ) {
501 $slice = true;
502 }
503 }
504 }
505 }
506 }
507 if ($slice == true) {
508 echo '<div style="width:100%; margin-top: 20px; margin-bottom: auto;"><img src="'.plugins_url('/images/slice_logo_dark_176x62.svg', __FILE__).'" width="88" weight="31"/>&nbsp;&nbsp;Osta kohe, maksa hiljem. Kolmes võrdses osas 3 x '.sprintf("%.2f",$price_incl_tax/3).' €</div>'; // sprintf("%.2f",$price_incl_tax/3).' in month
509 }
510 }
511 }
512 // Slice Promo 1
513 add_action( 'woocommerce_after_add_to_cart_button', 'wc_mc_shop_slice_button', 20 );
514
515 // if (mk_wc_version("3.4.0")) {
516 add_filter('woocommerce_get_settings_advanced', 'mk_admin_api_settings', 10, 2);
517 add_action('woocommerce_get_sections_advanced', 'mk_admin_add_api_settings');
518 add_filter('woocommerce_get_settings_api', 'mk_admin_api_settings', 10, 2);
519 // } else {
520 add_action('woocommerce_get_sections_api', 'mk_admin_add_api_settings');
521 add_action('woocommerce_settings_saved', 'mk_admin_save_api_settings', 30, 0);
522 add_filter("plugin_action_links_".plugin_basename(__FILE__), 'mk_admin_plugin_settings_link' );
523 // }
524
525 function __get_logo_html() {
526 return '<div class="makecommerce-info">'.
527 '<div class="makecommerce-logo">'.
528 '<a target="_blank" href="http://maksekeskus.ee"><img src="'. plugins_url('/images/makecommerce_logo_en.svg', __FILE__) .'" class="makecommerce-logo"></a>'.
529 '</div>'.
530 '<div class="makecommerce-links">'.
531 '<div class="makecommerce-link"><a target="_blank" href="https://merchant.maksekeskus.ee">Merchant Portal</a></div>'.
532 '<div class="makecommerce-link"><a target="_blank" href="https://makecommerce.net/">makecommerce.net</a></div>'.
533 '<div class="makecommerce-link"><a target="_blank" href="http://maksekeskus.ee">maksekeskus.ee</a></div>'.
534 '</div>'.
535 '</div>';
536 }
537
538 /* add new column (makecommerce_payment_method) to orders list */
539 function wc_makecommerce_payment_method_order_column($columns)
540 {
541 $columns['makecommerce_payment_method'] = __('Payment method (MC)');
542 return $columns;
543 }
544
545 add_filter('manage_edit-shop_order_columns', 'wc_makecommerce_payment_method_order_column');
546
547 // Make custom column sortable
548 add_filter( "manage_edit-shop_order_sortable_columns", 'makecommerce_payment_method_sortable' );
549 function makecommerce_payment_method_sortable($columns)
550 {
551 $meta_key = 'makecommerce_payment_method';
552 return wp_parse_args(array('makecommerce_payment_method' => $meta_key), $columns);
553 }
554
555 /* fill content for makecommerce_payment_method */
556 function wc_makecommerce_payment_method_order_column_content($column)
557 {
558 global $post;
559
560 if ('makecommerce_payment_method' === $column) {
561 echo get_post_meta($post->ID, '_makecommerce_preselected_method', true);
562 }
563 }
564
565 add_action('manage_shop_order_posts_custom_column', 'wc_makecommerce_payment_method_order_column_content');
566 }
567