Commit 96736d7b authored by mattwire's avatar mattwire
Browse files

Fix for non-default Wordpress basepage and AJAX reload of payment elements

parent f4bb36d4
......@@ -285,10 +285,11 @@
// /civicrm/payment/form? occurs when a payproc is selected on page
// /civicrm/contact/view/participant occurs when payproc is first loaded on event credit card payment
// On wordpress these are urlencoded
return (url.match("civicrm(\/|%2F)payment(\/|%2F)form") !== null) ||
(url.match("civicrm(\/|\%2F)contact(\/|\%2F)view(\/|\%2F)participant") !== null) ||
(url.match("civicrm(\/|\%2F)contact(\/|\%2F)view(\/|\%2F)membership") !== null) ||
(url.match("civicrm(\/|\%2F)contact(\/|\%2F)view(\/|\%2F)contribution") !== null);
var basePage = CRM.config.isFrontend ? CRM.vars.payment.basePage : 'civicrm';
return (url.match(basePage + "(\/|%2F)payment(\/|%2F)form") !== null) ||
(url.match(basePage + "(\/|\%2F)contact(\/|\%2F)view(\/|\%2F)participant") !== null) ||
(url.match(basePage + "(\/|\%2F)contact(\/|\%2F)view(\/|\%2F)membership") !== null) ||
(url.match(basePage + "(\/|\%2F)contact(\/|\%2F)view(\/|\%2F)contribution") !== null);
},
/**
......
......@@ -261,8 +261,19 @@ function mjwshared_civicrm_buildForm($formName, &$form) {
return;
}
// On Wordpress frontend we may have a different basePage (eg. mysite.com/mycrm/contribute/transact)
// CRM.payment.isAJAXPaymentForm requires the basePage to compare URLs.
$basePage = 'civicrm';
if (CRM_Core_Config::singleton()->userFramework === 'WordPress') {
$wpBasePage = \Civi::settings()->get('wpBasePage');
if (!empty($wpBasePage)) {
$basePage = $wpBasePage;
}
}
$jsVars = [
'jsDebug' => (boolean) \Civi::settings()->get('mjwshared_jsdebug'),
'basePage' => $basePage,
];
\Civi::resources()->addVars('payment', $jsVars);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment