Skip to content

Commit

Permalink
DOT.js fix json answer naming protocol: daemon_*** (in old systems) v…
Browse files Browse the repository at this point in the history
…s *** (in new systems), now supporting both
  • Loading branch information
lleokaganov committed Mar 4, 2024
1 parent 12948c2 commit 306d8df
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions common/DOT.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ presta_init: function(cx) {
// перехатываем только нашу FORM.onsubmit
var e=document.querySelector('FORM[action*="'+cx.module_name+'"]');
if(!e) return DOT.error("Prestashop DOT plugin: Design error!");
e.onsubmit=function(x) { DOT.all_submit(); };
e.onsubmit=function(x) { DOT.all_submit(); return false; };

/*
// debug option
Expand Down Expand Up @@ -269,6 +269,8 @@ ajax_process_errors: function(s0) {
}

try { var json=JSON.parse(s); } catch(e) { return DOT.error("Json error: ["+DOT.h(s0)+"]"); }
// патчим старый формат
for(var n in json) { if(n.substring(0,7)=='daemon_') { json[n.substring(7)]=json[n]; } }

if(json.error) {

Expand Down Expand Up @@ -318,9 +320,6 @@ all_submit: async function(y) {
// можно указать свой альтернативный AJAX для особых уродцев типа WooCommerce
var s = await DOT[( DOT.AJAX_ALTERNATIVE ? 'AJAX_ALTERNATIVE' : 'AJAX' )]( cx.ajax_url, data );

// DOT[( DOT.AJAX_ALTERNATIVE ? 'AJAX_ALTERNATIVE' : 'AJAX' )](
// cx.ajax_url,
// async function(s) {
var json=DOT.ajax_process_errors(s); if(!json) return false;
var ans = (''+json.result).toLowerCase(); // (waiting, paid)

Expand All @@ -338,16 +337,12 @@ all_submit: async function(y) {
}

// Paid
if( ans = 'paid' ) {
if( ans == 'paid' ) {
if(DOT.onpaid) { DOT.onpaid(json); return true; }
else return DOT.error('Paid success. What?! Ask admin, what can we do now?');
}

// debugger;
return DOT.error('ERROR OPT:\n\n '+JSON.stringify(json));
// },
// data
// );
// return false;
},


Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 306d8df

Please sign in to comment.