Order details do not load - opencart

Shipping Method & Payment Method doesn't show at all but after I click Update Tools button it shows up. When I check the script it's called and loaded via AJAX.
Login to admin panel. Go to Sales > Orders > Click edit an order > Click Totals tab. Look at Order Details table below.
Here's a screenshot before I click Update Tools
And after I click on Update Tools
Here's the script which shows selectbox
<select name="payment">
<option value=""><?php echo $text_select; ?></option>
<?php if ($payment_code) { ?>
<option value="<?php echo $payment_code; ?>" selected="selected"><?php echo $payment_method; ?></option>
<?php } ?>
</select>
It seems $payment_code doesn't contain any loop that's why it doesn't seem to load all before I click the button.
The question is: Is it correct or is it a bug?
Did anyone ever take a look at payment and shipping method loading at all without clicking on "Update Tools" button?
I have compared with original script and the script is exactly the same.
Opencart Version: 1.5.6

It's correct, it shouldn't be a loop. $payment_code and $payment_method aren't arrays, they just contain one entry (the order's current payment method). Have a look at the getForm() method in the sale/order controller to confirm:
if (isset($this->request->post['payment_code'])) {
$this->data['payment_code'] = $this->request->post['payment_code'];
} elseif (!empty($order_info)) {
$this->data['payment_code'] = $order_info['payment_code'];
} else {
$this->data['payment_code'] = '';
}
This has been a headache a few times for some of my clients. I believe it's because it doesn't bother to calculate all relevant shipping methods in case you change the address. Ideally it should, and would recalculate when you change zone, but it doesn't, so... there ya go! Not a bug, just not ideal functionality.

Related

Changes to the code - I do not see on the site

Got a question. For example, I change the code on the page
/catalog/view/theme/nextdef/template/extension/module/latest.twig
, or rather add a handler to the button:
<i class = "fa fa-heart" onclick = "window.dataLayer = window.dataLayer || [];
dataLayer.push ({'event': 'heart'}); "> </i> </button>
But when you click on this element, there are no changes. If you look at the page code, then it is also not updated. Although I write the cache and update the Disable cache inside the browser too, and still no changes ... I would be grateful if you help. thank
The problem was that the template editor had a history of this page. And there was no code. Apparently, he referred to her. I did not know that opencart prioritizes history compared to server files.

how can we create a position for the 2.0.1.1 opencart version

Opencart has a four layout left ,right Top and a Bottom.Adding new custom positions manually is not impossible of course, but ideally that needs to be done at the core.
Something like "header-bottom" or "footer-top" would be very useful for many modules, like "Menus" and "Slideshows".
how can we create a position like as above for the 2.0.1.1 opencart version
please help me thanks
I m making
footer_top POSITION similarly you can make any position
Add code in
opencart2\catalog\controller\common\home.php line 15(you can
understand where to put this line or ask it)
$data['footer_top'] = $this->load->controller('common/footer_top');
And Add this code in opencart2\catalog\view\theme\default\template\common\home.tpl
on line 13
<div id="content" class="col-sm-12"><?php echo $footer_top; ?></div>
copy -> opencart2\catalog\controller\common\content_top.php
to ----> opencart2\catalog\controller\common\footer_top.php
And change line 44
from
$modules = $this->model_design_layout->getLayoutModules($layout_id, 'content_top');
to
$modules = $this->model_design_layout->getLayoutModules($layout_id, 'footer_top');
Open opencart2\admin\view\template\design\layout_form.tpl and add this
code In select position dropdown options
<?php if ($layout_module['position'] == 'footer_top') { ?>
<option value="footer_top" selected="selected">footer top</option>
<?php } else { ?>
<option value="footer_top">footer top</option>
<?php } ?>
And Add below code after
html += ' < option value="content_top"><?php echo $text_content_top; ?>< /option>';
line in addmodule() function
html += ' < option value="footer_top">footer top< /option>';
And check in Position
opencart2/admin/index.php?route=design/layout/edit&token=7ddf86dsfdsfsdfdsfsdfdsfsdf5df&layout_id=1

Foundation Reveal Modal and HTML5 history API manipulation

I am trying to solve an issue with modals. What I want to do is allow the user to click the browser's back button to dismiss a modal and return to the original state of the page, this is: without modal. For such purpose I thought about using HTML 5 history API.
I started trying to append a querystring parameter to the URL, such as http://...page.html?show_modal=[yes|no] but I ended leaving this approach because I couldn't handle all the stuff involving popstate event, pageshow event, etc. I couldn't make it work and it overwhelmed me.
Then I tried with a more simple approach involving a hash appended to the URL, such as http://...page.html#modal, and the hashchange event. This approach is working better for me and I almost have it.
When the user clicks the button to show the modal, he or she can click the browser's back button and it will dismiss the modal. Furthermore, after that, the user can click the browser's forward button and it will show the modal again. Very nice! The user can also navigate directly to the URL with the hash to access directly this state of the page, as well as he or she can bookmark such state of the page. It's working pretty neat and I'm rather happy with the results.
The problem is that it is not working totally perfect. When the user dismiss the modal by clicking the background, the ESC key or the X in the upper right corner, the history starts to mess up. Try it: open the modal by clicking on the button, then click the background to dismiss it (look a the URL in the address bar, first problem here is that the hash isn't removed), then click your browser back button and you will see it isn't working correctly. You will end with a duplicate in your history and you have to click the back button twice in order to go to the previous page. This is not desirable from an UX viewpoint. Does anyone know a solution to this?
I provide my code in this CodePen and at the end of this question. I suggest trying it in your own machine and NOT IN Codepen, so you can view the hash in the URL, etc. Also, it doesn't work in Codepen Full mode, I don't know why.
Thanks!!
I am using Foundation 5.2.1
HTML
<div class="row">
<div class="small-12 columns">
<h1>Reveal Modal</h1>
<h2>Manipulation of the browser history for a better UX</h2>
<a class="button radius" href="#" data-reveal-id="sampleModal" id="button">Show Modal...</a>
</div>
</div>
<!-- ############# -->
<!-- MODAL -->
<!-- ############# -->
<div id="sampleModal" class="reveal-modal medium" data-reveal>
<h2>Hi!</h2>
<p>You may think you are on a new page now, but you aren't. Try to click your browser <kbd>Back</kbd> button to dismiss this modal and return to the the page you were viewing.</p>
<a class="close-reveal-modal">×</a>
</div>
JavaScript
function setModalHash(url, present) {
var a = $('<a>', { href:url } )[0]; // http://tutorialzine.com/2013/07/quick-tip-parse-urls/
var newHash = "";
if (present === true) {
newHash = "#modal";
}
// Build the resulting URL
result = a.protocol + "//" + a.hostname + ":" + a.port + a.pathname + a.search + newHash;
return result;
}
$("#button").on('click', function() {
history.pushState(null, null, setModalHash(document.URL, true));
});
$(window).on("hashchange load",function(e) {
// Handling also the load event allows navigation directly to http://host/path/to/file#modal and bookmarking it
if (document.location.hash == "#modal") {
$("#sampleModal").foundation("reveal","open");
}
else {
$("#sampleModal").foundation("reveal","close");
}
});
I've been messing with the history api/History.js in combination with session storage to maintain modal state, and open/close based upon user navigation. I've finally achieved about 90% of my goal, but history is implemented very poorly in Safari and iOS Safari so remove the features for these browsers.
Some of the problems you may be running into with the hash approach is that when you use the # with pushstate it actually doesn't push a new object into the history state. It sometimes seems to push history onto the stack and you could use history.back() to fire a popstate, but if you were to say refresh the page with your hashurl and do some sort of check for hash on page initiation, there doesn't seem to be a new history pushed onto the stack, and therefore on backwards navigation the user will leave the site rather than closing the modal.
Here is my implementation working for all browsers except for where it falls back to normal behavior is Safari:
http://dtothefp.github.io/hosted_modal_history_sample/
https://github.com/dtothefp/html5history_express_modal_toggle
Like I said I use History.js in combination with sessionstorage because annoyingly enough, in the popstate for closing the modal the history object is removed, which is exactly when I would need it. In all a very poorly implemented API.
I don't change the URL because this project does not have a backend, so if I change the URL with no hash, on page refresh the page would not be found. An alternate implementation would be a query string, which will properly update history when used in the pushstate, but ends up being bad UX because if the user closes the modal not using the backwards navigation (i.e. hitting the cancel button or clicking off), removing the query string would result in a page refresh.

Getting dropdown value from template django

I am facing an issue working with django ( using shopcart ). I want to add a select options field to change dynamically an item suscription in the cart, but I am not getting the value selected from the template.
In my template where I display the cart I have :
<form action="" method="GET">{%csrf_token%}
<select name="suscr" title="suscr">
<option value="" selected>Suscribe</option>
<option value="1" name="suscr" >Weekly</option>
<option value="2" name="suscr">Monthly</option>
</select>
</form>
I want to select an option and then, if I press 'Checkout' to have the cart updated.
Appart from that, I believe its missing a method modifying the item in cart.py.
Any ideas would help.
Thanks
The above form is inside a loop
{% for item in cart %}
What i propose you to do is not python-oriented but all javascript for the most part as, from the description, we assume that what you are dealing with is going all at the client-side.
As you are dealing with a shopping cart, what i'd do is storing what the user is checking in a sessionStorage so that the information would persist while the user navigates through your website even with multiple tabs. As the user might just be "walking around" you shopping website, there's no need to push things to the database without even knowing if the user wants that. Just remove the form and keep with the select, then you get what the user selected appending an attribute to select: <select onchange=my_function(this.value)>...</select> and then, inside my_functionin a script change whatever you want to the page.
When the user enters the shopping cart page you show him what he selected so far getting the items from the sessionStorageand then, if he/she confirms that wants to buy, then submit a form to the server-side, update the database and proccess that as your workflow states.
tl;dr: store the options in sessionStorage, just post to the server at the end.
For help on the server-side update your question with more info about the cart.py

How can I add a "trending topics" section to my site's homepage?

I would like to add a custom "trending topics" section to my news website at the top of the homepage. An existing example that shows precisely what I am looking for is the Daily Beast homepage.
I would like to do this with custom code or with a plugin, but not as a widget. Does anyone know how I can do this in a flexible way that can easily customize to style and look of my website.
My site is a Spanish language 24/7 news website called Yasta.pr. Thx!
it depends on how you are storing your data in your database but you can try this:
add a div section in the header of your webpage above the menu bar.
then you can dynamically add the most trending topic to it automatically when the page starts by inserting this code inside it:
<div id="*id_name">
$query = "SELECT * FROM *table_name ORDER BY *most_trending_column LIMIT 1";
mysql_select_db(*database_name, *connection);
$result = mysql_query($query) or die(mysql_error());
$data = mysql_fetch_assoc($result);
echo "<h3 id='*id_name'>" . $data['*title_column_name'] . "</h3>";
</div>
dont forget to connect to your database first.