Skip to content

Commit

Permalink
update entry status after wc order complete, currency field improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
RensTillmann committed Jan 8, 2021
1 parent 4f17634 commit edbdd0b
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 17 deletions.
6 changes: 4 additions & 2 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

- [PDF Generator Add-on](https://renstillmann.github.io/super-forms/#/pdf-generator-add-on)

## Jan 08, 2021 - Version 4.9.573

## Jan 06, 2021 - Version 4.9.573

- **Added:** `WooCommerce Checkout Add-on` option to update Contact Entry status after WooCommerce order completed
- **Added:** Option for google autocomplete to return `The place's name`, `Formatted phone number`, `International phone number` and `Website of the business`
- **Improved:** When using google autocomplete the code will now determine what data is being used in your form, and strip out any unnecessary data from the API request which could considerably reduce costs
- **Improved:** Focus/Filled status for currency field
- **Fix:** JavaScript error on currency field when `Number format` contained space(s)

## Jan 04, 2021 - Version 4.9.572

Expand Down
4 changes: 4 additions & 0 deletions src/add-ons/super-forms-woocommerce/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Jan 08, 2021 - Version 1.7.3
- Added: Option to update contact entry status after woocommerce order was
completed

Dec 17, 2020 - Version 1.7.2
- Fix: `{loop_value}` not being replaced if value was empty when `WooCommerce Checkout`
Add-on is used in combination with the `Send email after order completed`
Expand Down
36 changes: 30 additions & 6 deletions src/add-ons/super-forms-woocommerce/super-forms-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Plugin Name: Super Forms - WooCommerce Checkout
* Plugin URI: http://codecanyon.net/item/super-forms-drag-drop-form-builder/13979866
* Description: Checkout with WooCommerce after form submission. Charge users for registering or posting content.
* Version: 1.7.2
* Version: 1.7.3
* Author: feeling4design
* Author URI: http://codecanyon.net/user/feeling4design
* Text Domain: super-forms
Expand All @@ -38,7 +38,7 @@ final class SUPER_WooCommerce {
*
* @since 1.0.0
*/
public $version = '1.7.2';
public $version = '1.7.3';


/**
Expand Down Expand Up @@ -514,7 +514,9 @@ public static function update_order_meta( $order_id ) {

$_super_entry_id = $woocommerce->session->get( '_super_entry_id', array() );
if( isset($_super_entry_id['entry_id']) ) {
update_post_meta( $order_id, '_super_entry_id', $_super_entry_id['entry_id'] );
update_post_meta( $_super_entry_id['entry_id'], '_super_contact_entry_wc_order_id', $order_id );
$woocommerce->session->set( '_super_entry_id', array() );
}
}
}
Expand All @@ -527,15 +529,14 @@ public static function update_order_meta( $order_id ) {
*/
public function order_status_changed( $order_id, $old_status, $new_status ) {
if( $new_status=='completed' ) {
$contact_entry_id = get_post_meta( $order_id, '_super_entry_id', true );
$_super_wc_post = get_post_meta( $order_id, '_super_wc_post', true );
if ( !empty( $_super_wc_post ) ) { // @since 1.0.2 - check if not empty
$my_post = array(
'ID' => $_super_wc_post['post_id'],
'post_status' => $_super_wc_post['status'],
);
wp_update_post( $my_post );


}

// Update user login status and role
Expand Down Expand Up @@ -564,9 +565,12 @@ public function order_status_changed( $order_id, $old_status, $new_status ) {
if (method_exists('SUPER_Common','get_form_settings')) {
$form_settings = SUPER_Common::get_form_settings($form_id);
}else{
$settings = get_post_meta(absint($form_id), '_super_form_settings', true);
$form_settings = get_post_meta(absint($form_id), '_super_form_settings', true);
}
// Update contact entry status after succesfull payment
if( !empty($form_settings['woocommerce_completed_entry_status']) ) {
update_post_meta( $contact_entry_id, '_super_contact_entry_status', $form_settings['woocommerce_completed_entry_status'] );
}

if( !empty($form_settings['woocommerce_completed_email']) ) {

$global_settings = get_option( 'super_settings' );
Expand Down Expand Up @@ -1280,6 +1284,13 @@ public static function before_email_success_msg( $atts ) {
* @since 1.0.0
*/
public static function add_settings( $array, $settings ) {
$statuses = SUPER_Settings::get_entry_statuses();
$new_statuses = array();
foreach($statuses as $k => $v) {
$new_statuses[$k] = $v['name'];
}
$statuses = $new_statuses;
unset($new_statuses);
$array['woocommerce_checkout'] = array(
'hidden' => 'settings',
'name' => esc_html__( 'WooCommerce Checkout', 'super-forms' ),
Expand Down Expand Up @@ -1410,6 +1421,19 @@ public static function add_settings( $array, $settings ) {
'filter_value' => 'true',
),


'woocommerce_completed_entry_status' => array(
'name' => esc_html__( 'Entry status after payment completed', 'super-forms' ),
'label' => sprintf( esc_html__( 'You can add custom statuses via %sSuper Forms > Settings > Backend Settings%s if needed', 'super-forms' ), '<a target="blank" href="' . esc_url(admin_url() . 'admin.php?page=super_settings#backend-settings') . '">', '</a>' ),
'default' => SUPER_Settings::get_value(0, 'woocommerce_completed_entry_status', $settings['settings'], 'completed' ),
'type' => 'select',
'values' => $statuses,
'filter' => true,
'parent' => 'woocommerce_checkout',
'filter_value' => 'true',
),


// @since 1.3.8 - option to send email after payment completed
'woocommerce_completed_email' => array(
'name' => esc_html__( 'Send email after order completed', 'super-forms' ),
Expand Down
9 changes: 5 additions & 4 deletions src/assets/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3294,12 +3294,13 @@ function SUPERreCaptcha(){
};
SUPER.after_field_change_blur_hook = function(args){
if( typeof args.el !== 'undefined' ) {
if(args.el.value===''){
if(args.el.closest('.super-shortcode')) {
if(args.el.closest('.super-shortcode')){
args.el.closest('.super-shortcode').classList.remove('super-focus');
if(args.el.value===''){
args.el.closest('.super-shortcode').classList.remove('super-filled');
}else{
args.el.closest('.super-shortcode').classList.add('super-filled');
}
}else{
if(args.el.closest('.super-shortcode')) args.el.closest('.super-shortcode').classList.add('super-filled');
}
}
args.form = SUPER.get_frontend_or_backend_form(args);
Expand Down
7 changes: 6 additions & 1 deletion src/assets/js/frontend/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@
decimal: $decimal_seperator,
precision: $decimals
});
$(this).maskMoney('mask', this.dataset.defaultValue);
if(this.dataset.defaultValue!==''){
$(this).maskMoney('mask', this.dataset.defaultValue);
$(this).parents('.super-currency').addClass('super-filled');
}else{
$(this).parents('.super-currency').removeClass('super-filled');
}
});
};

Expand Down
4 changes: 2 additions & 2 deletions src/assets/js/frontend/masked-currency.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
var integerPart = value.slice(0, decimalPointIndex),
decimalPart = value.slice(decimalPointIndex + 1);
value = integerPart + settings.decimal + decimalPart +
new Array((settings.precision + 1) - decimalPart.length).join(0);
new Array((settings.precision + 1) - (decimalPart.length - settings.format.length)).join(0);
}
} else if (decimalPointIndex > 0) {
// if the precision is 0, discard the decimal part
Expand Down Expand Up @@ -588,4 +588,4 @@
$.error("Method " + method + " does not exist on jQuery.maskMoney");
}
};
})(window.jQuery || window.Zepto);
})(window.jQuery || window.Zepto);
6 changes: 4 additions & 2 deletions src/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

- [PDF Generator Add-on](https://renstillmann.github.io/super-forms/#/pdf-generator-add-on)

## Jan 08, 2021 - Version 4.9.573

## Jan 06, 2021 - Version 4.9.573

- **Added:** `WooCommerce Checkout Add-on` option to update Contact Entry status after WooCommerce order completed
- **Added:** Option for google autocomplete to return `The place's name`, `Formatted phone number`, `International phone number` and `Website of the business`
- **Improved:** When using google autocomplete the code will now determine what data is being used in your form, and strip out any unnecessary data from the API request which could considerably reduce costs
- **Improved:** Focus/Filled status for currency field
- **Fix:** JavaScript error on currency field when `Number format` contained space(s)

## Jan 04, 2021 - Version 4.9.572

Expand Down

0 comments on commit edbdd0b

Please sign in to comment.