Auto refresh of the cart - ajax

When I have two items in the cart, I open a second tab where it also shows two items
and now if I add another item then the cart(second tab) will show a total of 3 items.
Now The question is, if I go back to the first tab, how can I see three items in the cart without refreshing the tab.
Auto refresh of the cart: When I have two items in the cart, I open a second tab where it also shows two items
and now if I add another item then the cart(second tab) will show a total of 3 items.
Now The question is, if I go back to the first tab, how can I see three items in the cart without refreshing the tab.

Here, you are two ways: 1. Call ajax requests to server every approx.
2 seconds, this depends on your server configuration. If server can handle frequent ajax requests.
Using LocalStorage object, there will be no frequent ajax requests and server will be free for other requests. You have to call for/while loop for any change in qty. This is security risk but depends on what you store in LocalStorage. Never store sensitive data. Please ref. https://www.w3schools.com/html/html5_webstorage.asp

Related

Oracle Apex - Display Items based on number of values

I have a regular link on an Interactive Report:
That links sends the Deal Number information into a different page where the user will be able to update all product information.
As per customer request, I need to use items. Issue is, that I need to show one textfield item per Product, so for example:
If Peter is selected (as per my snap above), I would need to show 2 textfield Items, one for Product 'ABC' and another for Product 'XYZ'.
If John is selected, I would need to show 3 textfield Items, one for 'Product1', one for 'Product2' and another for 'Product3'.
Is there a way to achieve this dynamic display of items?
If so, how can I make Item 1 to show Product1 info, Item 2 to show Product2 info and so on?
Thanks
There are a couple of routes you can take, each one has it's pros and cons.
1. the APEX_ITEM API
This is an API that renders apex items, as part of a sql query or in a static region with pl/sql source (not tested that last option)
Pro:
a lot of flexibility
Cons:
Look and feel is "old" - doesn't look anything like the modern page items that exist in the universal theme and you're stuck with that old look and feel. Lots of hardcoded pl/sql.
2. A fixed number of pre-created items.
Create a number of items and populate only the ones you need, eg P1_PRODUCT1_NAME, P1_PRODUCT2_NAME, ... .If you only need a single product then you're populate only P1_PRODUCT1_NAME, else you'd use as much as you need. With server sided conditions you hide/show the ones not needed/needed
Pro:
All the bells & whistles for look and feel you have in "normal" forms
Cons:
Can't render more products than what you created items for in your page. What if you create fields for 10 products but you need 11 ?
3. Interactive Grid.
I know "the customer wants items" but this component is specifically written for this purpose. I'd definitely consider this as an option - maybe you can make the customer change his mind.
Pro:
Very modern apex component, highly configurable. Check the interactive grid cookbook for a ton of advanced examples.
Cons:
Not items - this is tabular form/spreadsheet layout. Not all end users like them as a form of data entry.

How to clear data using a button? LARAVEL

Scenario: My website does shoe orders. When a user proceeds into buying a shoe, it goes to pending orders. My problem is that when the user presses the back button of the browser, the order data is loaded and still be available to be purchased and proceed to pending orders.
Is there a way that I can make the back button of the browser to erase the order details after proceeding to pending orders?
check this answer - that should do the trick, BUT it's quite common that if you add goods to the cart, it stays there and it doesn't matter if you pressed the back button or not.
So, is it really necessary to catch this scenario? Is it causing any problem? If so, I would personally use a cron job to remove unpain pending orders (in the last X hours)

Codeigniter cart Library not working properly

I have used cart library for adding updating and deleting items in carts. I am counting number cart items not quantity. I am counting number of item in navigation header which will be including in all pages. But when i navigate to different pages cart item will not be the same. If i added 2 items in cart in home page it shows 2. when i navigate to about us page it it will automatically setting to 1. if i use cart count why it will display different count in different page? Help me with this.

magento increment bundle product quantity on options page

I am building an on-line store to sale sweets. I added sweets box as bundle products. Before buying sweet, customer has to select box first. each box will have limit on quantity. for example box 1 contains 4 sweets, box 2 contains 12 etc. After selecting box, on options page, suppose I selected box 1. I selected 4 sweets. now I want to buy few more sweets. so there is a need to have an Ajax call to increment box quantity.Please help me with this. Thanks in advance.
It is my advice that you find a different way. I think you are suggesting using ajax to change the product (to a different bundle) and then move the 4 sweets from the initial bundle to the new bundle. That is a very complicated thing to do. An full answer here would need many lines of code.
I suggest you allow the user to pick the sweets first, then ask them to pick a box - the box must be big enough so you might give your box products an attribute sweets_maximum and set that to 4 or 12 and use some logic to only display boxes that are big enough.
Then maybe the cost of the sweets is zero and the boxes non-zero (so you can apply the price for the box and not the sweets).
Alternatively, load the sweet_maximum and the bundle SKUs and all the sweets skus into one webpage and after the user selects the number of sweets, write code to pass back to Magento the correct SKUs to add to the cart ie 10 different sweets SKUs and the SKU for box 2.
Bundles are very complex. I don't think you want to be ajaxing them back and forth.
*EDIT following comment below
Then this (from my answer above) is my recomendation: do everything in the browser and then pass back to Magento only the box and sweets chosen - your Javascript would form the URL to the bundle controller with the appropriate product selections.
*Alternatively, load the sweet_maximum and the bundle SKUs and all the sweets skus into one webpage and after the user selects the number of sweets, write code to pass back to Magento the correct SKUs to add to the cart ie 10 different sweets SKUs and the SKU for box 2.*
If you really want to use ajax you are going to be jumping through a lot of hoops. Here is the psuedo code I would use. You can find the functions by using the defualt Magento theme and capturing the submission URLs from the bundle pages and the cart-updates and reading the code in the controller actions.
(server side)display the chosen bundle
(browser side)UI logic to decide when a different box is needed
NO, WAIT. Maybe we need more information; it is difficult to do a full code architecture in this forum.
//new psuedo code
Carry on as normal. Allow the user to pick any box and any number of sweets through out the entire shopping experience
Eventually the user will visit its cart.
As part of the cart display logic, count the total sweets and count the total box capacity. If box capacity < total sweets, prompt the user to choose a bigger box.
Why do I say this? I mean there is a lot of shopping scenarios to work out but if you are really doing these as bundles then the bundle is not in the cart until the user presses the add to cart button - that is why I say the browser should have the logic to change the box in the browser without ajaxing anything. Can a user buy sweets separately?
I don't know what to say. I am happy to help you but we are opening a can of worms as far as the logic is concerned and without a specific list of all shopping scenarios and all allowed buying logic I find it difficult to assist. But I think if you write down all the logic you will find the answer yourself. Don't be afraid to advise your client on different ways to do this.
The URL for adding a bundle to the cart is:
POST http://54.247.95.57/checkout/cart/add/product/13831/ HTTP/1.1
product=13831&related_product=&bundle_option%5B767%5D=3867&bundle_option_qty%5B767%5D=1&
The URL for removing a bundle is :
POST http://54.247.95.57/checkout/cart/updatePost/ HTTP/1.1
update_cart_action=update_qty&cart%5B48677%5D%5Bqty%5D=0
But I still say do it all in the browser.

Magento - How to load a set of products below, based on product selection?

I have to develop a shopping site in Magento, it will have 5 tabs.
In the first tab, I have to display 10 different products.
Based on the selection in first tab, I have to display another set of products in the second tab.
Likewise, other 3 tabs will display related products based on previous tab's selection.
Each tab will have more than 10 products
User should at least select 1 product from each tab.
Please let me know, how to achieve this? Expecting help from Magento experts.
Make 5 tabs in HTML, write a functionality to get all the products in first tab (other 4 tabs empty) when the page loads. When user selects a product in the first tab, fire an ajax call which will bring data and fill the second tab. Likewise, when user selected product from 2nd tab, fire ajax which brings data and fills the 3rd tab, and same goes for 4th and 5th tab.
So, finally, you will have to fire 4 ajax calls for reaching to the final tab. Now, you can just write one function only where you can pass the parameter with some product ID and step number, so that you can narrow down the filteration based on step numbers criteria.

Resources