Changing the Intershop JumpTargets on an AJAX request - intershop

Is there a way to change the JumpTarget per request?
During the checkout flow the shipping methods are updated and a fresh cart is calculated. I'd like to do the same with an ajax call on my customized checkout flow. What I'm seeing is the jumpTarget is wrong and returns the wrong page:
Wrong:
JumpTarget=ViewCheckoutAddresses-Review returns payment page
Correct: JumpTarget=ViewCheckoutShipping-Review should return updated payment methods
==========
UPDATE:
All I needed to do was satisfy the pipeline params by including the correctly named 'name' field on the submit button. I could also use a hidden field to set the jumpTarget.

It is actually really hard to answer this question without actually debugging what is going on in your pipeline. I would suggest that you start the pipeline debugger and look what flow it follows. Then see what the standard checkout does (non ajax based) and see where your flow differs. It might just be that you are missing some input parameters and therefor it tries to send you back to the previous step.

Related

Google App Maker Widget Validate on Datasource select

I have three different fields/textbox widgets, that rely on querying the same data source to be checked to avoid duplication. For reasons, I do not want to turn on the unique/required for those three fields.
I put some code to check for validation. My problem is that when I call the form's validate function, it takes some time till the validation comes back with an error message. However the form's validate returns immediately and allows people to click Submit.
How can I avoid this problem?
Block till validation kicks (setTimeout function?)
Set a separate invisible field such as working and set the validationError on the field and clear after validations clear? This will probably be a numeric field so that I can wait for all streams in parallel to finish.
Final question. is Validate a blocking function as it goes through the fields? I am guessing Yes.

How can a SyliusCart convert into an SyliusOrder

I am using the SyliusCartBundle, SyliusFlowBundle and the SyliusOrderBundle in a project. So I have declared an own Cart, CartItem model and a CartManager. I'm using the cart without problems, but how can I convert this cart into an order?
Do I have to handle with an order model all the time?
What would be the preferred way to handle this use case in Sylius?
And where is the http://docs.sylius.org/en/latest/bundles/SyliusOrderBundle/builder.html? I can't find the OrderBuilder class in the SyliusOrderBundle.
What I figured is that in Sylius the only difference between cart and order is in the status.
What I mean is that there is only one order table and one order items table. When you add some item to your cart then it gets saved to the order/order items tables with a specific status, which will change once you check out, once you pay succesfully, etc etc.
It makes sense if you think about it.
So what converts your cart entries to order entries is the event listeners that respond to cart/order lifecycle events triggered by the controllers. In your case by the checkout flow.
The documentation is a bit old and in the process of being rewritten (I think).
Your best option in my opinion is to check out https://github.com/Sylius/Sylius
It is a full working app based on all the sylius bundles, and you can play with it to understand how it works. Check out the event listeners that the CoreBundle registers.
If you look into the CoreBundle/Model folder you will see that Sylius\Bundle\CoreBundle\Model\Order extends Sylius\Bundle\CartBundle\Model\Cart
HTH

how to disable reaching ajax call from browser

I have following ajax call
open: function () {
$(this).load("MyBox.aspx?sec=L&levId=" + RowId);
}
so people can see the querystring, so the user can copy url and paste it to browser but how can i block that? I dont want it to shown from browser. How I can do that? I m using asp.net and jquery.
load function issues a GET request. Instead of that, you may use a jQuery POST call and get the data. Users can't get the result by pasting it in browser and hit enter (which is GET request)
var thatObject=$(this);
$.post("MyBox.aspx?sec=L&levId=" + RowId,function(response){
thatObject.html(response);
})
In the server page, you can read the values posted by checking the Request.Form collection (instead of Request.QueryString).
from msdn
The Form collection retrieves the values of form elements posted to
the HTTP request body, with a form using the POST method.
You can determine whether the call is a GET call or POST call by inspecting the Request.RequestType property value. This way you can avoid people issuing GET request to this method and getting the response.
But remember that, there are tools/browser addons which does the POST request from browser.
Also if the data is for authorized users, you may check the user is authorized to access it in the server page(MYbox.aspx) before returning the content.
You can't. You can never trust any code running on the client. If you need to hide data on the client, you should create a server based session and then put a session token in an encrypted cookie.
From wikipedia and W3C
Some methods (for example, HEAD, GET, OPTIONS and TRACE) are defined as safe, which means they are intended only for information retrieval and should not change the state of the server. In other words, they should not have side effects, beyond relatively harmless effects such as logging, caching, the serving of banner advertisements or incrementing a web counter.
Making arbitrary GET requests without regard to the context of the application's state should therefore be considered safe.
By contrast, methods such as POST, PUT and DELETE are intended for actions that may cause side effect
If your get request changes the state of the server (which it most likely does based on your post), you are doing something wrong. What you're trying to do is impossible. You need to rethink your architecture.

How do I display data from an external database in Drupal?

I am building a custom module that will allow my users to do a simple query against an MS SQL database. I've built the form using hook_form() and have gotten validation to work.
I'm planning on retrieving the data from hook_form_submit(), but once I've done that, how do I append it below the form? It does not appear that I have access to $output from hook_form_submit(). I'm at a loss as to what to do next.
Thanks
Dana
When you are rendering the form you should check for $form_state['values'] to see if the user has already submitted a form when you're rendering the form. Then you could paint the form results in the same step as painting the form.
The first time the user loads the form page the $form_state variable won't contain any submitted form info so you can render an empty results table.
There's a good illustration of the Drupal Form API workflow on Drupal.org here: Form API Internal Workflow Illustration
The problem in trying to output data in the hook_form() method is that the method gets invoked twice which clears the post values the second time through. Throw a dpm($form_state) in the hook_form() function and you'll see two sets of post data. One with values and one without.
So after dissecting the built in Search module, which pretty much operates exactly the way I want my form to work, I figured out how this is done. Well, at least one way you can do it.
What Search module does is take the values from $form_state in hook_form_submit() and pastes them into the URL, then it sets the $form_state['redirect'] to that new URL, effectively storing those variables in the URL and changing the POST to a GET.
Now, in the callback, they extract those values from the URL, do the search on them, THEN they call drupal_get_form(), append the results to the end and return it.
There's another solution HERE where they use SESSION to store the values until the second trip through. Weird, but it works.

ASP.NET MVC - How To Refresh View From Actionmethod as a response to request?

I have an action-method in a controller that takes requests coming from a variety of different views.
It is somewhat of a utility method and I simply want it to accept the parameters it is given - do something - and then refresh the view that sent the request.
Right now, the only way I see to do this is by having the method figure out what view sent it the info and do a:
return RedirectToAction("method", "controller");
For each possibility (or something similar to that).
Is there a more general way I can make my method just re-render the current view without having to explicitly identify it?
-Thanks
Your best bet is to use jQuery to post the data then utilize the results as you see fit. Otherwise you can pass in the action/controller name in the post and use them dynamically to redirect.

Resources