Skip to content

Commit ec0910d

Browse files
Release 1.1.12
1 parent cb44cd5 commit ec0910d

22 files changed

+551
-111
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ This repository contains the PostFinance Checkout WooCommerce plugin that enable
1313

1414
## Documentation
1515

16-
* [Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/woocommerce/1.1.11/docs/en/documentation.html)
16+
* [Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/woocommerce/1.1.12/docs/en/documentation.html)
1717

1818
## License
1919

20-
Please see the [license file](https://github.com/pfpayments/woocommerce/blob/1.1.11/LICENSE) for more information.
20+
Please see the [license file](https://github.com/pfpayments/woocommerce/blob/1.1.12/LICENSE) for more information.
2121

2222

2323

assets/css/admin.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
width: 2em
9292
}
9393

94-
.order_actions .postfinancecheckout-button-download-invoice::after {
94+
.order_actions .postfinancecheckout-button-download-invoice::after, .widefat .wc_actions .postfinancecheckout-action-button.wallee-button-download-invoice::after {
9595
font-family: woocommerce-wallee;
9696
speak: none;
9797
font-weight: 400;
@@ -109,7 +109,7 @@
109109
margin: 0px;
110110
}
111111

112-
.order_actions .postfinancecheckout-button-download-packingslip::after {
112+
.order_actions .postfinancecheckout-button-download-packingslip::after, .widefat .wc_actions .postfinancecheckout-action-button.wallee-button-download-packingslip::after {
113113
font-family: woocommerce-wallee;
114114
speak: none;
115115
font-weight: 400;

assets/css/checkout.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* PostFinance Checkout WooCommerce
3+
*
4+
* This WooCommerce plugin enables to process payments with PostFinance Checkout (https://www.postfinance.ch).
5+
*
6+
* @author customweb GmbH (http://www.customweb.com/)
7+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Software License (ASL 2.0)
8+
*/
9+
/* Order button disabled */
10+
#place_order.postfinancecheckout-disabled{
11+
cursor:not-allowed;
12+
}

assets/js/frontend/checkout.js

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ jQuery(function($) {
6969
var self = event.data.self;
7070
var current_method = self.get_selected_payment_method();
7171
if (!self.is_supported_method(current_method)) {
72+
self.enable_place_order_button();
7273
return;
7374
}
7475
var configuration = $("#postfinancecheckout-method-configuration-"
@@ -77,6 +78,7 @@ jQuery(function($) {
7778
.data("configuration-id"), configuration
7879
.data("container-id"));
7980
self.handle_description_for_empty_iframe(current_method);
81+
self.handle_place_order_button_status(current_method);
8082
},
8183

8284
handle_description_for_empty_iframe : function(method_id) {
@@ -112,10 +114,10 @@ jQuery(function($) {
112114
}
113115

114116
if (((!description || description == "false")
115-
&& this.payment_methods[method_id]['height'] == 0) || !has_full_address) {
117+
&& this.payment_methods[method_id].height == 0) || !has_full_address) {
116118
item.css('position', 'absolute');
117119
item.css('left', '-100000px');
118-
} else if ((this.payment_methods[method_id]['height'] == 0) || !has_full_address) {
120+
} else if ((this.payment_methods[method_id].height == 0) || !has_full_address) {
119121
item.find("p").css("margin-bottom", 0);
120122
form.css('position', 'absolute');
121123
form.css('left', '-100000px');
@@ -128,7 +130,28 @@ jQuery(function($) {
128130
form.css('left', '');
129131
}
130132
},
131-
133+
134+
handle_place_order_button_status: function(method_id){
135+
if(!this.payment_methods[method_id].button_active){
136+
this.disable_place_order_button();
137+
}
138+
else{
139+
this.enable_place_order_button();
140+
}
141+
},
142+
143+
enable_place_order_button: function(){
144+
var order_button = $('#place_order');
145+
order_button.removeAttr('disabled');
146+
order_button.removeClass('postfinancecheckout-disabled');
147+
},
148+
149+
disable_place_order_button: function(){
150+
var order_button = $('#place_order');
151+
order_button.prop('disabled', true);
152+
order_button.addClass('postfinancecheckout-disabled');
153+
},
154+
132155
register_ajax_prefilter : function() {
133156
var self = this;
134157
$.ajaxPrefilter(
@@ -176,7 +199,8 @@ jQuery(function($) {
176199
register_method : function(method_id, configuration_id, container_id) {
177200
if (typeof window.IframeCheckoutHandler == 'undefined') {
178201
this.payment_methods[method_id] = {
179-
height : 0
202+
height : 0,
203+
button_active : true
180204
};
181205
return;
182206
}
@@ -203,6 +227,7 @@ jQuery(function($) {
203227
configuration_id : configuration_id,
204228
container_id : tmp_container_id,
205229
handler : window.IframeCheckoutHandler(configuration_id),
230+
button_active : true,
206231
height : 0
207232
};
208233
this.payment_methods[method_id].handler
@@ -211,13 +236,23 @@ jQuery(function($) {
211236
});
212237
this.payment_methods[method_id].handler
213238
.setHeightChangeCallback(function(height) {
214-
self.payment_methods[method_id]['height'] = height;
239+
self.payment_methods[method_id].height = height;
215240
self.handle_description_for_empty_iframe(method_id)
216241
});
217242

218243
this.payment_methods[method_id].handler.setInitializeCallback(function(){
219244
$(self.checkout_form_identifier).unblock();
220245
});
246+
247+
this.payment_methods[method_id].handler.setEnableSubmitCallback(function(){
248+
self.payment_methods[method_id].button_active=true;
249+
self.handle_place_order_button_status(method_id);
250+
});
251+
252+
this.payment_methods[method_id].handler.setDisableSubmitCallback(function(){
253+
self.payment_methods[method_id].button_active=false;
254+
self.handle_place_order_button_status(method_id);
255+
});
221256

222257
this.payment_methods[method_id].handler
223258
.create(self.payment_methods[method_id].container_id);

changelog.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@
8181

8282
= 1.1.11 - September 20, 2018 =
8383

84-
* FIxes - Improved handling of backend actions
84+
* Fixes - Improved handling of backend actions
85+
86+
= 1.1.12 - November 13, 2018 =
87+
88+
* Feature - Added option to send global product attributes to PostFinance Checkout
89+
* Tweak - Improved customer experience if the payment failes.
8590

8691
= 1.1.2 - May 22, 2018 =
8792

docs/en/documentation.html

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ <h2>Documentation</h2> </div>
2121
</a>
2222
</li>
2323
<li>
24-
<a href="https://github.com/pfpayments/woocommerce/releases/tag/1.1.11/">
24+
<a href="https://github.com/pfpayments/woocommerce/releases/tag/1.1.12/">
2525
Source
2626
</a>
2727
</li>
@@ -368,10 +368,30 @@ <h2>
368368
</div><div class="paragraph">
369369
<p>If this does not solve the problem, make sure no other plugin is hiding the payment methods.</p>
370370
</div> </div>
371+
</div> <div class="section" id="_how_can_i_send_the_product_attributes_to_whitelabelname">
372+
<div class="section-title">
373+
<h2>
374+
<span class="title-number">8.2</span>How can I send the product attributes to PostFinance Checkout? </h2>
375+
</div>
376+
<div class="section-body">
377+
<div class="admonitionblock note">
378+
<table>
379+
<tr>
380+
<td class="icon">
381+
<div class="title">Note</div>
382+
</td>
383+
<td class="content">
384+
It is only possible to send the global product attributes to PostFinance Checkout, the custom product attributes are not supported.
385+
</td>
386+
</tr>
387+
</table>
388+
</div><div class="paragraph">
389+
<p>To send a product attribute to PostFinance Checkout edit the attribute in Products &#8594; Attributes, select the option <strong>Send attribute to PostFinance Checkout.</strong> and save.</p>
390+
</div> </div>
371391
</div> <div class="section" id="_how_can_i_update_the_plugin">
372392
<div class="section-title">
373393
<h2>
374-
<span class="title-number">8.2</span>How can I update the plugin? </h2>
394+
<span class="title-number">8.3</span>How can I update the plugin? </h2>
375395
</div>
376396
<div class="section-body">
377397
<div class="paragraph">
@@ -381,7 +401,7 @@ <h2>
381401
</div> <div class="section" id="_how_can_i_translate_the_plugin">
382402
<div class="section-title">
383403
<h2>
384-
<span class="title-number">8.3</span>How can I translate the plugin? </h2>
404+
<span class="title-number">8.4</span>How can I translate the plugin? </h2>
385405
</div>
386406
<div class="section-body">
387407
<div class="olist arabic">
@@ -520,13 +540,18 @@ <h1>
520540
<span class="item-title">How can I make the payment methods appear in the checkout?</span>
521541
</a>
522542
</li> <li class="nav-level-2">
523-
<a href="#_how_can_i_update_the_plugin">
543+
<a href="#_how_can_i_send_the_product_attributes_to_whitelabelname">
524544
<span class="item-number">8.2</span>
545+
<span class="item-title">How can I send the product attributes to PostFinance Checkout?</span>
546+
</a>
547+
</li> <li class="nav-level-2">
548+
<a href="#_how_can_i_update_the_plugin">
549+
<span class="item-number">8.3</span>
525550
<span class="item-title">How can I update the plugin?</span>
526551
</a>
527552
</li> <li class="nav-level-2">
528553
<a href="#_how_can_i_translate_the_plugin">
529-
<span class="item-number">8.3</span>
554+
<span class="item-number">8.4</span>
530555
<span class="item-title">How can I translate the plugin?</span>
531556
</a>
532557
</li> </ul>

includes/admin/class-wc-postfinancecheckout-admin-document.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static function add_buttons_to_overview(WC_Order $order){
5757
'postfinancecheckout_admin' => 'download_invoice'
5858
), admin_url('post.php')), 'download_invoice', 'nonce');
5959
$title = esc_attr(__('Invoice', 'woo-postfinancecheckout'));
60-
printf('<a class="button tips postfinancecheckout-button-download-invoice" href="%1s" data-tip="%2s">%2s</a>', $url, $title, $title);
60+
printf('<a class="button tips postfinancecheckout-action-button postfinancecheckout-button-download-invoice" href="%1s" data-tip="%2s">%2s</a>', $url, $title, $title);
6161
}
6262
if ($transaction_info->get_state() == \PostFinanceCheckout\Sdk\Model\TransactionState::FULFILL) {
6363
$url = wp_nonce_url(
@@ -68,7 +68,7 @@ public static function add_buttons_to_overview(WC_Order $order){
6868
'postfinancecheckout_admin' => 'download_packing'
6969
), admin_url('post.php')), 'download_packing', 'nonce');
7070
$title = esc_attr(__('Packing Slip', 'woo-postfinancecheckout'));
71-
printf('<a class="button tips postfinancecheckout-button-download-packingslip" href="%1s" data-tip="%2s">%2s</a>', $url, $title, $title);
71+
printf('<a class="button tips postfinancecheckout-action-button postfinancecheckout-button-download-packingslip" href="%1s" data-tip="%2s">%2s</a>', $url, $title, $title);
7272
}
7373
}
7474

includes/admin/class-wc-postfinancecheckout-admin-settings-page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public function get_settings(){
145145
$settings = array(
146146
array(
147147
'links' => array(
148-
'https://plugin-documentation.postfinance-checkout.ch/pfpayments/woocommerce/1.1.11/docs/en/documentation.html' => __('Documentation', 'woo-postfinancecheckout'),
148+
'https://plugin-documentation.postfinance-checkout.ch/pfpayments/woocommerce/1.1.12/docs/en/documentation.html' => __('Documentation', 'woo-postfinancecheckout'),
149149
'https://www.postfinance-checkout.ch/user/signup' => __('Sign Up', 'woo-postfinancecheckout')
150150
),
151151
'type' => 'postfinancecheckout_links',

includes/admin/class-wc-postfinancecheckout-admin.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ private function init_hooks(){
9595
$this,
9696
'remove_not_wanted_order_actions'
9797
), 10, 2);
98+
99+
add_action('woocommerce_after_edit_attribute_fields', array(
100+
$this,
101+
'display_attribute_options_edit'
102+
), 10, 0);
103+
104+
add_action('woocommerce_after_add_attribute_fields', array(
105+
$this,
106+
'display_attribute_options_add'
107+
), 10, 0);
108+
109+
98110
}
99111

100112
public function handle_woocommerce_active(){
@@ -219,6 +231,45 @@ public function plugin_action_links($links){
219231
return array_merge($action_links, $links);
220232
}
221233

234+
235+
236+
public function store_attribute_options($product, $data_storage){
237+
global $postfinancecheckout_attributes_options;
238+
if(!empty($postfinancecheckout_attributes_options)){
239+
$product->add_meta_data('_postfinancecheckout_attribute_options', $postfinancecheckout_attributes_options, true);
240+
}
241+
}
242+
243+
244+
245+
public function display_attribute_options_edit(){
246+
247+
$edit = absint( $_GET['edit'] );
248+
$checked = false;
249+
250+
$attribute_options = WC_PostFinanceCheckout_Entity_Attribute_Options::load_by_attribute_id($edit);
251+
if($attribute_options->get_id() > 0 && $attribute_options->get_send()){
252+
$checked = true;
253+
}
254+
echo '<tr class="form-field form-required">
255+
<th scope="row" valign="top">
256+
<label for="postfinancecheckout_attribute_option_send">'.esc_html__( 'Send attribute to PostFinance Checkout.', 'woo-postfinancecheckout' ).'</label>
257+
</th>
258+
<td>
259+
<input name="postfinancecheckout_attribute_option_send" id="postfinancecheckout_attribute_option_send" type="checkbox" value="1" '.checked( $checked, true, false).'/>
260+
<p class="description">'.esc_html__( 'Should this product attribute be sent to PostFinance Checkout as line item attribute?', 'woo-postfinancecheckout' ).'</p>
261+
</td>
262+
</tr>';
263+
}
264+
265+
public function display_attribute_options_add(){
266+
echo '<div class="form-field">
267+
<label for="postfinancecheckout_attribute_option_send"><input name="postfinancecheckout_attribute_option_send" id="postfinancecheckout_attribute_option_send" type="checkbox" value="1">'.esc_html__( 'Send attribute to PostFinance Checkout.', 'woo-postfinancecheckout' ).'</label>
268+
<p class="description">'.esc_html__( 'Should this product attribute be sent to PostFinance Checkout as line item attribute?', 'woo-postfinancecheckout' ).'</p>
269+
</div>';
270+
}
271+
272+
222273
}
223274

224275
WC_PostFinanceCheckout_Admin::instance();

includes/class-wc-postfinancecheckout-gateway.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public function payment_fields(){
292292
wp_localize_script('postfinancecheckout-checkout-js', 'postfinancecheckout_js_params', $localize);
293293
}
294294
catch(Exception $e){
295-
$this->log($e->getMessage(), WC_Log_Levels::DEBUG);
295+
WooCommerce_PostFinanceCheckout::instance()->log($e->getMessage(), WC_Log_Levels::DEBUG);
296296
}
297297

298298
parent::payment_fields();
@@ -335,7 +335,7 @@ public function process_payment($order_id){
335335
$transaction_id = $session_handler->get('postfinancecheckout_transaction_id');
336336
$existing = WC_PostFinanceCheckout_Entity_Transaction_Info::load_by_order_id($order_id);
337337
if($existing->get_id() > 0 && $existing->get_state() != \PostFinanceCheckout\Sdk\Model\TransactionState::PENDING){
338-
WooCommerce_PostFinanceCheckout::instance()->add_notice(__('There was an issue, while processing your order. Please try again or use another payment method.', 'woo-postfinancecheckout'), 'error');
338+
WC()->session->set( 'postfinancecheckout_failure_message', __('There was an issue, while processing your order. Please try again or use another payment method.', 'woo-postfinancecheckout') );
339339
$order = wc_get_order($order_id);
340340
$order->update_status( 'failed' );
341341
WC()->session->set('reload_checkout', true);
@@ -383,7 +383,7 @@ public function process_payment($order_id){
383383
catch (Exception $e) {
384384
$message = $e->getMessage();
385385
$cleaned = preg_replace("/^\[[A-Fa-f\d\-]+\] /", "", $message);
386-
WooCommerce_PostFinanceCheckout::instance()->add_notice($cleaned, 'error');
386+
WC()->session->set( 'postfinancecheckout_failure_message', $cleaned);
387387
$order->update_status( 'failed' );
388388
if($is_order_pay_endpoint){
389389
$result =array(

0 commit comments

Comments
 (0)