PageSourceSearch

https://www.asociacioncomunicacionnoviolenta.org/wp-content/plugin…/assets/js/frontend/checkout.js?ver=12.6.0

js asociacioncomunicacionnoviolenta.org collected 2026-10-01 12:26:22 UTC 6,521 bytes, 181 lines download raw bytes

1/* global sumo_pp_checkout_params */
2
3jQuery( function( $ ) {
4    // sumo_pp_checkout_params is required to continue, ensure the object exists
5    if ( typeof sumo_pp_checkout_params === 'undefined' ) {
6        return false;
7    }
8
9    var block_wrapper = function() {
10        if ( 'cart' === sumo_pp_checkout_params.current_page ) {
11            return $( 'div.cart_totals' );
12        } else {
13            return $( '.woocommerce-checkout-payment, .woocommerce-checkout-review-order-table' ).closest( 'form' );
14        }
15    };
16
17    var is_blocked = function( $node ) {
18        return $node.is( '.processing' ) || $node.parents( '.processing' ).length;
19    };
20
21    /**
22     * Block a node visually for processing.
23     *
24     * @param {JQuery Object} $node
25     */
26    var block = function( $node ) {
27        if ( ! is_blocked( $node ) ) {
28            $node.addClass( 'processing' ).block( {
29                message : null,
30                overlayCSS : {
31                    background : '#fff',
32                    opacity : 0.6
33                }
34            } );
35        }
36    };
37
38    /**
39     * Unblock a node after processing is complete.
40     *
41     * @param {JQuery Object} $node
42     */
43    var unblock = function( $node ) {
44        $node.removeClass( 'processing' ).unblock();
45    };
46
47    var checkout = {
48        /**
49         * Manage Checkout page events.
50         */
51        sync : false,
52        isOrderPPEnabled : false,
53        paymentType : false,
54        depositedAmount : false,
55        paymentPlan : false,
56        init : function() {
57
58            this.onPageLoad();
59
60            $( document.body ).on( 'input:checkbox', '#_sumo_pp_enable_orderpp', this.preventdefault );
61            $( document ).on( 'change', '#_sumo_pp_enable_orderpp', this.toggleOrderPP );
62            $( document ).on( 'change', '#_sumo_pp_deposited_amount', this.updateOrderPPDepositedAmount );
63            $( document ).on( 'change', '#_sumo_pp_chosen_payment_plan', this.updateOrderPPPaymentPlan );
64            $( document ).on( 'updated_wc_div', this.mayBeDisplayOrderPP );
65            $( document ).on( 'updated_cart_totals', this.mayBeDisplayOrderPP );
66        },
67        onPageLoad : function() {
68            if ( 'checkout' === sumo_pp_checkout_params.current_page ) {
69                checkout.sync = true;
70            }
71
72            this.getOrderPP();
73        },
74        preventdefault : function( evt ) {
75            evt.preventDefault();
76        },
77        toggleOrderPP : function( evt ) {
78            evt.preventDefault();
79            checkout.sync = false;
80            checkout.getOrderPP();
81        },
82        updateOrderPPDepositedAmount : function( evt ) {
83            evt.preventDefault();
84            checkout.updateCheckout();
85        },
86        updateOrderPPPaymentPlan : function( evt ) {
87            evt.preventDefault();
88            checkout.updateCheckout();
89        },
90        mayBeDisplayOrderPP : function() {
91            $( 'table._sumo_pp_orderpp_fields tr:eq(1)' ).slideUp();
92
93            if ( $( '#_sumo_pp_enable_orderpp' ).is( ':checked' ) ) {
94                $( 'table._sumo_pp_orderpp_fields tr:eq(1)' ).slideDown();
95            }
96        },
97        getOrderPP : function() {
98            checkout.mayBeDisplayOrderPP();
99            checkout.updateCheckout();
100        },
101        populate : function() {
102            checkout.isOrderPPEnabled = $( '#_sumo_pp_enable_orderpp' ).is( ':checked' );
103            checkout.paymentType = $( '#_sumo_pp_payment_type' ).val();
104            checkout.depositedAmount = $( '#_sumo_pp_deposited_amount' ).val();
105            checkout.paymentPlan = $( '#_sumo_pp_chosen_payment_plan:checked' ).val();
106        },
107        updateCheckout : function() {
108            checkout.populate();
109
110            $.blockUI.defaults.overlayCSS.cursor = 'wait';
111            block( block_wrapper() );
112
113            $.ajax( {
114                type : 'POST',
115                url : sumo_pp_checkout_params.wp_ajax_url,
116                dataType : 'text',
117                async : checkout.sync ? false : true,
118                data : {
119                    action : '_sumo_pp_checkout_orderpp',
120                    security : sumo_pp_checkout_params.orderpp_nonce,
121                    enabled : checkout.isOrderPPEnabled ? 'yes' : 'no',
122                    payment_type : checkout.paymentType,
123                    deposited_amount : checkout.depositedAmount,
124                    chosen_payment_plan : checkout.paymentPlan,
125                },
126                success : function() {
127                    if ( 'checkout' === sumo_pp_checkout_params.current_page ) {
128                        checkout.forceRenderSignupFormIfGuest();
129
130                        $( document.body ).trigger( 'update_checkout' );
131                    }
132
133                    $( document.body ).trigger( 'sumopp_order_paymentplan_updated' );
134                },
135                complete : function() {
136                    unblock( block_wrapper() );
137
138                    if ( $( '.woocommerce-cart-form' ).length && 'cart' === sumo_pp_checkout_params.current_page ) {
139                        $( document.body ).trigger( 'wc_update_cart' );
140                    }
141
142                    checkout.clearCache();
143                }
144            } );
145        },
146        forceRenderSignupFormIfGuest : function() {
147            if ( sumo_pp_checkout_params.is_user_logged_in ) {
148                return false;
149            }
150
151            if ( $( 'p.create-account' ).length ) {
152                $( 'p.create-account' ).show();
153                $( 'div.create-account' ).slideUp();
154            }
155
156            if ( sumo_pp_checkout_params.maybe_prevent_from_hiding_guest_signup_form && sumo_pp_checkout_params.can_user_deposit_payment ) {
157                $( 'div.create-account' ).slideUp();
158            }
159
160            if ( checkout.isOrderPPEnabled ) {
161                if ( $( 'p.create-account' ).length ) {
162                    $( 'p.create-account' ).hide();
163                }
164                if ( $( 'div.create-account' ).length ) {
165                    $( 'div.create-account' ).slideDown();
166                }
167            }
168        },
169        clearCache : function() {
170            checkout.sync = false;
171            checkout.isOrderPPEnabled = false;
172            checkout.paymentType = false;
173            checkout.depositedAmount = false;
174            checkout.paymentPlan = false;
175        }
176    };
177
178    if ( sumo_pp_checkout_params.can_user_deposit_payment && $( '._sumo_pp_orderpp_fields' ).length ) {
179        checkout.init();
180    }
181} );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.