File tree 2 files changed +45
-0
lines changed
2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -722,4 +722,37 @@ document.addEventListener("DOMContentLoaded", function (event) {
722
722
} ) ;
723
723
}
724
724
} ) ;
725
+
726
+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
727
+ document . getElementById ( 'common-click-to-pay' ) . addEventListener ( 'click' , function ( ) {
728
+ var checkboxes = document . querySelectorAll ( '.offer-checkbox:checked' ) ;
729
+ var urls = [ ] ;
730
+
731
+ checkboxes . forEach ( function ( checkbox )
732
+ {
733
+ var productUrl = checkbox . getAttribute ( 'data-url' ) ;
734
+ var offerId = checkbox . getAttribute ( 'data-offer-id' ) ;
735
+ var offerUid = checkbox . getAttribute ( 'data-offer-uid' ) ;
736
+
737
+ var url = productUrl + ( productUrl . indexOf ( '?' ) !== - 1 ? '&' : '?' ) +
738
+ '__aewcoapi=1&woocommerce-offer-id=' + offerId +
739
+ '&woocommerce-offer-uid=' + offerUid ;
740
+ urls . push ( url ) ;
741
+ } ) ;
742
+
743
+ if ( urls . length > 0 ) {
744
+ function redirectToNext ( index ) {
745
+ if ( index < urls . length ) {
746
+ window . location . href = urls [ index ] ;
747
+ setTimeout ( function ( ) {
748
+ redirectToNext ( index + 1 ) ;
749
+ } , 2000 ) ;
750
+ }
751
+ }
752
+ redirectToNext ( 0 ) ;
753
+ } else {
754
+ alert ( 'Please select at least one offer.' ) ;
755
+ }
756
+ } ) ;
757
+ } ) ;
725
758
} ( jQuery ) ) ;
Original file line number Diff line number Diff line change 11
11
'offer_quantity ' => __ ('Quantity ' , 'offers-for-woocommerce ' ),
12
12
'offer-status ' => __ ('Status ' , 'offers-for-woocommerce ' ),
13
13
'offer-action ' => __ ('Action ' , 'offers-for-woocommerce ' ),
14
+ 'offer_checkbox ' => __ ('Select ' , 'offers-for-woocommerce ' ),
14
15
));
15
16
16
17
$ customer_offers = get_posts (apply_filters ('ofw_my_account_my_offers_query ' , array (
195
196
break ;
196
197
}
197
198
}
199
+ break ;
200
+ case 'offer_checkbox ' :
201
+ if ($ post_status === 'accepted-offer ' ) {
202
+ $ offer_url = $ offer_args ['product_url ' ] . (strpos ($ offer_args ['product_url ' ], '? ' ) ? '& ' : '? ' ) . '__aewcoapi=1&woocommerce-offer-id= ' . esc_attr ($ post_id ) . '&woocommerce-offer-uid= ' . esc_attr ($ offer_args ['offer_uid ' ]); ?>
203
+ <input type="checkbox" class="offer-checkbox" name="offer_select[]" value="<?php echo esc_attr ($ post_id ); ?> " data-url="<?php echo esc_url ($ offer_url ); ?> " data-offer-id="<?php echo esc_attr ($ post_id ); ?> " data-offer-uid="<?php echo esc_attr ($ offer_args ['offer_uid ' ]); ?> ">
204
+ <?php }
205
+ break ;
198
206
}
199
207
}
200
208
?>
206
214
?>
207
215
</tbody>
208
216
</table>
217
+
218
+ <div class="pay-button-wrapper">
219
+ <button id="common-click-to-pay" class="button"><?php _e ( 'Click to Pay ' , 'offers-for-woocommerce ' ); ?> </button>
220
+ </div>
209
221
<?php else : ?>
210
222
<h2 class="entry-title"><?php _e ( 'No Offers found ' , 'offers-for-woocommerce ' ); ?> </h2>
211
223
<?php endif ;
You can’t perform that action at this time.
0 commit comments