I'm customizing OpenCart 3.
By clicking a button in front-page footer, a modal panel opens which includes an iframe
, like this:
<footer>
<div class="container">
<div class="content">
<i class="fa fa-plus-circle" aria-hidden="true" data-toggle="modal" data-target="#myModal"></i>
<div class="modal fade bd-example-modal-lg" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fa fa-times-circle" aria-hidden="true"></i></button>
<iframe width="100%" height="{{ img_h }}" src="{{ addnewpro }}"></iframe>
</div>
</div>
</div>
</div>
</div>
iframe
contains a php page for entering a new product which locates in admin panel.
So far everything is OK! The problem is I can't find a way to close the opened modal
(#myModal) after entering the new product and saving it. I tried many different approaches including session, etc.
I Created Session after adding product in php page:
$this->session->data['newprosaved'] = 'saved';
I checked session in footer's php page:
if (isset($this->session->data['newprosaved'])) {
$data['saved'] = $this->session->data['newprosaved'];
unset($this->session->data['newprosaved']);
}
Then tried to access it in footer.twig:
<script type="text/javascript"><!--
$(document).ready(function() {
if ('{{ saved }}' == 'saved' && $('#myModal').hasClass('in')) {
$('#myModal').modal('hide');
$('#myModal').remove();
}
});
</script>
But it doesn't work!
Is there any other method to do it?