-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow custom extensions on backend and frontend #416
Comments
Interesting idea, @neekfenwick. I'll give that additional thought over the weekend and see if I can provide some possibilities. |
With the Dojo framework I'm used to having two eventing mechanisms, either 1/ a class you're developing can extend from Evented (https://dojotoolkit.org/reference-guide/1.9/dojo/Evented.html) and call I can't see a similar centralised event bus in jQuery, the closest I can see is to use |
@lat9 Just wanted to mention another point where I find a modification is required in my case. Not everything can be done via the Ajax handler, some more work needs doing on initial page load in the PHP. When the checkout_one page first loads, there may be a Near the end of
In this way, the header and the Ajax handler both trigger the same observer, to get whatever data is required about the payment method. This new variable So, the PHP code now needs to have explicit knowledge of a message DOM node, instead of my first implementation which dynamically created the message DOM node in response to the Ajax call. But, this message node is not used at all by the core addon, it's only given a message to display by my custom observer responding to The changes are getting more intrusive than I first thought, more core modifications to the addon, so you may want to have some input. |
Noting that the |
I have half an idea and am wondering how to solve the other half, maybe you can help me out on the Javascript side.
When a customer selects a specific payment method in our store, we want to show a warning message next to the Submit button on One Page Checkout. Normally, changing payment method calls zcAjaxOnePageCheckout::updatePaymentMethod, which returns an array of data containing order_totals output, error message etc. My hack solution so far is:
show_submit_message
element to the array returned fromupdatePaymentMethod
depending on the value of$_SESSION['payment']
, containing the message to show.jquery.checkout_one.js
response handler from callingupdatePaymentMethod
to check the returned object forshow_submit_message
and add a<div>
if it's present.float:right
and adding a<div>
there causes the submit button to left align in that floated container meaning it jumps to the left of the page.A simple solution on the PHP side is to add a
$this->notify()
call near the end ofupdatePaymentMethod
so an observer can modify the returned array. This would be one code modification to this project. My problem comes on the Javascript side. What is the correct way to introduce custom behaviour hooks to the javascript code, similar toNotifierManager
?A quick look tells me I could use Ajax Events https://api.jquery.com/Ajax_Events/ to add a hook function to every request, and inspect each one for
updatePaymentMethod
, but this seems pretty clumsy.Is there a more elegant way in jQuery?
The text was updated successfully, but these errors were encountered: