PHP Classes

File: assets/js/admin/integration.js

Recommend this page to a friend!
  Classes of Julio Cezar Kronbauer  >  PHP WooCommerce Correios  >  assets/js/admin/integration.js  >  Download  
File: assets/js/admin/integration.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP WooCommerce Correios
Woocommerce plugin for shipping via Correios
Author: By
Last change:
Date: 5 years ago
Size: 1,034 bytes
 

Contents

Class file image Download
/* global ajaxurl, WCCorreiosIntegrationAdminParams */
jQuery( function( $ ) {

	/**
	 * Admin class.
	 *
	 * @type {Object}
	 */
	var WCCorreiosIntegrationAdmin = {

		/**
		 * Initialize actions.
		 */
		init: function() {
			$( document.body ).on( 'click', '#woocommerce_correios-integration_autofill_empty_database', this.empty_database );
		},

		/**
		 * Empty database.
		 *
		 * @return {String}
		 */
		empty_database: function() {
			if ( ! window.confirm( WCCorreiosIntegrationAdminParams.i18n_confirm_message ) ) {
				return;
			}

			$( '#mainform' ).block({
				message: null,
				overlayCSS: {
					background: '#fff',
					opacity: 0.6
				}
			});

			$.ajax({
				type: 'POST',
				url: ajaxurl,
				data: {
					action: 'correios_autofill_addresses_empty_database',
					nonce: WCCorreiosIntegrationAdminParams.empty_database_nonce
				},
				success: function( response ) {
					window.alert( response.data.message );
					$( '#mainform' ).unblock();
				}
			});
		}
	};

	WCCorreiosIntegrationAdmin.init();
});
For more information send a message to info at phpclasses dot org.