Logging: - Replace custom file logger with wc_get_logger() (source: woolist-phplist) - Logs now appear in WooCommerce → Status → Logs, no filesystem access needed - Remove log viewer / Clear Log from settings page (WC UI handles this) - Keep "Enable debug logging" checkbox to control DEBUG-level verbosity Order page meta box: - New "phpList Sync" side meta box on every order edit page - Works with both classic (shop_order) and HPOS (woocommerce_page_wc-orders) - Shows billing email + dropdown of all configured lists - "Add to phpList" button triggers AJAX subscribe, shows inline result - Result and full API trace logged to WC logs under woolist-phplist source - woolist-admin.js handles button state and response display Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
/* global ajaxurl, jQuery */
|
|
( function ( $ ) {
|
|
'use strict';
|
|
|
|
$( document ).on( 'click', '.woolist-manual-subscribe-btn', function () {
|
|
var $btn = $( this );
|
|
var $box = $btn.closest( '.woolist-metabox-wrap' );
|
|
var $resp = $box.find( '.woolist-metabox-response' );
|
|
var listId = $box.find( '.woolist-list-select' ).val();
|
|
|
|
$resp.hide().removeClass( 'woolist-mb-success woolist-mb-error' ).html( '' );
|
|
$btn.prop( 'disabled', true ).text( 'Subscribing\u2026' );
|
|
|
|
$.ajax( {
|
|
url: ajaxurl,
|
|
method: 'POST',
|
|
data: {
|
|
action: 'woolist_manual_subscribe',
|
|
nonce: $btn.data( 'nonce' ),
|
|
order_id: $btn.data( 'order-id' ),
|
|
list_id: listId,
|
|
},
|
|
} )
|
|
.done( function ( response ) {
|
|
if ( response.success ) {
|
|
$resp.addClass( 'woolist-mb-success' ).html( '✓ ' + response.data.message );
|
|
} else {
|
|
$resp.addClass( 'woolist-mb-error' ).html( '✗ ' + response.data.message );
|
|
}
|
|
$resp.show();
|
|
} )
|
|
.fail( function () {
|
|
$resp.addClass( 'woolist-mb-error' ).html( '✗ Request failed.' ).show();
|
|
} )
|
|
.always( function () {
|
|
$btn.prop( 'disabled', false ).text( 'Add to phpList' );
|
|
} );
|
|
} );
|
|
|
|
} )( jQuery );
|