feat: WC-native logging + Add to phpList button on order page
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>
This commit is contained in:
40
woolist-phplist/assets/js/woolist-admin.js
Normal file
40
woolist-phplist/assets/js/woolist-admin.js
Normal file
@@ -0,0 +1,40 @@
|
||||
/* 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 );
|
||||
Reference in New Issue
Block a user