Add image products in order history opencart 3 - opencart

I've just tried more than one option in different ways....
one of here:
in file \catalog\controller\account\order.php
after
'name' => $product['name'],
added
'image' => $image,
front
$data['products'][] = array(
inserted
$this->load->model('tool/image');
$image = $this->model_tool_image->resize($product_info['image'], 50, 50);
in template \catalog\view\theme\default\template\account\order_list.twig
<img src="{{ product.image }}" alt="{{ product.name }}" title="{{ product.name }}"

Related

removing more than a character using cut

So I'm trying to search for Elements using query selector, the problem is, due to the way theses IDs are generated (with the name of regions, stores, and sale type, from the context) some of then includes spaces or dots on them which don't let them be searched.
I have identified the spaces were breaking my searches before and used cut to remove the spaces from IDs.
Is there a way to use cut to remove diferent characters as if I'm using cascaded replaces (in python) or replaceAlls (in JS) to make these ids don't have any spaces or dots? I tried using pipes but it didn't work. how can I do it?
Snippet of the formation of the elements:
{% if data.nivel == "N0" %}
<tr id="family_{{ data.familia_produto|cut:" " }}" class="bu_name_line {{ data.nivel }} title0"
data-level="{{ data.nivel }}" data-family="{{ data.familia_produto }}"
data-regional="{{ data.nome_regional }}" data-segment="{{ data.segmento }}"
data-bu-name="{{ data.nome_filial }}" onclick="show_lines('N1','{{ data.familia_produto }}')">
<td id='bu_name' onmouseenter='hight_light(this)' onmouseleave='hight_light(this)'>
{{ data.familia_produto }}
</td>
{% elif data.nivel == "N1" %}
<tr id="regional_{{ data.familia_produto|cut:" " }}_{{ data.nome_regional|cut:" " }}"
class="bu_name_line {{ data.nivel }} title1 hide" data-level="{{ data.nivel }}"
data-family="{{ data.familia_produto }}" data-regional="{{ data.nome_regional }}"
data-segment="{{ data.segmento }}" data-bu-name="{{ data.nome_filial }}"
onclick="show_lines('N2A','{{ data.familia_produto }}','{{ data.nome_regional }}')">
<td id='bu_name' onmouseenter='hight_light(this)' onmouseleave='hight_light(this)'>
{{ data.nome_regional }}
</td>
Snippet of the selection I'm trying to do to catch this elements:
if (level_name[0] == 'family'){
var forecast_lines = line.parentElement.querySelectorAll(`[id*=regional_${level_name[1]}]`)
}else if (level_name[0] == 'regional'){
var forecast_lines = line.parentElement.querySelectorAll(`[id*=filial_${level_name[1]}_${level_name[2]}]`)
}else if (level_name[0] == 'filial'){
//console.log("entrei aqui 222222222")
var forecast_lines = line.parentElement.querySelectorAll(`[id*=segmento_${level_name[1]}_${level_name[2]}_${level_name[3]}]`)
error:
Uncaught DOMException: Element.querySelectorAll: '[id*=segmento_CAFES_INTERNA_GER.INT.COMERCIAL]' is not a valid selector
Don't know exactly how is your code but it will give you an idea:
should_removed_list = [" ", ".", ",", "="]
for i in should_removed_list:
if str(i) in your_content:
your_content.replace(str(i), "")

Jinja2 - Expressions concatenating issue

I've got this variable
{% set img = Bicycles[Keys[i]][2] %} which is a string
I'm trying to add it to an img html element like this
<img src="{{ url_for('static', filename=' {{ img }} ') }}" class="card-img-top" alt="...">
My expected output when the page loads is
<img src="{{ url_for('static', filename='theurlhere') }}" class="card-img-top" alt="...">
But all i get is this "/static/%20%7B%7B%20img%20%7D%7D%20"
I'm so lost e_e
you need to concatenate the variable img. instead of using {{ img }} use '~img~'
This is a link to a similar question asked here
String concatenation in Jinja

I want to add a custom png image instead of glyphicon in admin menu section in opencart 2.3x and 3x?

how do i update this, in column_left controller?
if ($catalog) {
$data['menus'][] = array(
'id' => 'menu-catalog',
'icon' => 'fa-tags',
'name' => $this->language->get('text_catalog'),
'href' => '',
'children' => $catalog
);
}
you can't because it is hardcoded for evey menu,
and even you manage to get this done , some other extension you installed still need that update fix
in column left controller
'icon' => 'fa-tags', chaange it to 'icon' => 'glyphicon glyphicon-user'
nothing to change in view , it will work ,
You should customize the html in "admin/view/template/common/column_left.twig"
For example .. replace this code :
{% if menu.href %}<i class="fa {{ menu.icon }} fw"></i> {{ menu.name }}
by:
{% if menu.href %}{% if menu.img %}<img src="{{ menu.img }}"> {{ menu.name }}{% else %}<i class="fa {{ menu.icon }} fw"></i> {{ menu.name }}{% endif %}
and adding the image path in menu array item in column_left controller :
'img' => 'view/image/file.png'

How to set vue data to the value of a form?

I have a flask page that is for editing blog posts. It has the following vue:
<form method="POST" action="{{ url_for('edit',itemid=item.id) }}" id="text-input">
{{ form.csrf_token }}
<div style="margin-left:30px;margin-top:20px;">
Title: {{ form.title }}
</div>
<br/>
<div id="editor">
Content: {{ form.content( **{':value':'input','#input': 'update'}) }}
<div v-html="compiledMarkdown"></div>
</div>
<br/>
Category: {{ form.category|safe }}
<br/>
<input type="submit" value="Save">
</form>
<script>
new Vue({
el: '#editor',
data: {
input: "starting data"
},
computed: {
compiledMarkdown: function () {
return marked(this.input, { sanitize: true })
}
},
methods: {
update: _.debounce(function (e) {
this.input = e.target.value
}, 300)
}
});
</script>
What I would like to do is have a starting value for input based on something sent in by flask. Basically I would change input: "starting data" to input: {{ form.content.data }}. However, when I do this, it stops updating the input when I change the text in the box. I think I am kind of hardcoding the data to be whatever what in form.content.data as opposed to a string.
How can I pass this in so that it starts with the form.content.data value yet is still changeable?
The reason it didn't work was because {{ form.content.data }} appears in the template as raw text.
Thus it was trying to use something like: the brown fox jumped over the lazy dog
and this doesn't compile to a javascript object. Adding quotes around the {{ form.content.data }} like '{{ form.content.data }}' fixed it.

#if statement using URL parameter laravel blade

I am new to laravel and blade. I'm a student doing a simple 'job seeker' assignment. I have 2 different types of users - jobseekers (category 1) and employers (category 2). When I create a new user from buttons in layout.blade.php, users will click on a register (category 1) link or an Employer Button (category 2), I want to pass the category on to the create.blade.php so that I can stylise it depending on what category they are, and of course keep that information hidden from the actual User.
I'm not sure what code you want to see, but I'll start with my layout.blade.php - when the link or button is clicked, it redirects to create.blade.php and the url updates to either category 1 or categoy 2 - depending on what is clicked. I want to add an #if statement as to which create for gets displayed, one jobseeker or one for employer (they have slightly different options)
layout.blade.php
<div class="col-sm-9">
#if (!Auth::check())
<div class="login-form">
{{ Form::open(array('action' => 'UserController#login')); }}
{{ Form::text('username', null, array('class' => 'input-small', 'placeholder' => 'Email')); }}
{{ Form::password('password', array('class' => 'input-small', 'placeholder' => 'Password')); }}
{{ Form::submit('Sign in', array('class' => 'btn btn-danger')); }}
{{ Form::close(); }}
{{ Form::open(array('action' => 'UserController#create')); }}
{{link_to_route('user.create', 'or Register here', ['category' => 1] )}}
</div>
{{link_to_route('user.create', 'Employers', ['category' => 2], array('class' => 'btn btn-primary')) }}
#endif
#yield('content1')
create.blade.php
#extends('job.layout')
#section('content1')
#if('category' == 2)
<h1>New Employer page</h1>
{{ Form::open(array('action' => 'UserController#store')); }}
{{ Form::text('username', null, array('class' => 'input-small', 'placeholder' => 'Email')); }}
<p>{{ Form::password('password', array('class' => 'input-small', 'placeholder' => 'Password')); }}
{{ Form::hidden('category', 2) }}
{{ Form::label('name', 'Name:', array('class' => 'col-sm-3')) }}
{{ Form::text('name') }}
{{ Form::label('description', 'Company Description:', array('class' => 'col-sm-3')) }}
{{ Form::text('description') }}
{{ Form::label('industry', 'Industry', array('class' => 'col-sm-3')) }}
{{ Form::text('industry') }}
{{ Form::label('phone', 'Phone Number:', array('class' => 'col-sm-3')) }}
{{ Form::text('phone') }}
<p>{{ Form::submit('Sign in'); }}
{{ Form::close(); }}
#else
<p>just a test for New User Page
#endif
#stop
The create page so far just results in getting the #else condition back. ie: "just a test for New User Page"
Thanks in advance
i will avoid all your codes because you are making it way complicated than it is.
i will explain in step by step.
make two views. one for job seeker, one for employer.
depending upon the category, load the respective view. that's all you want.
let's come to code.
Routes.php
Route::get('create/{category}', array(
'as' => 'create',
'uses' => 'UserController#create'
));
UserController
public function create($category)
{
if($category==1)
return View::make('seeker');
elseif($category==2)
return View::make('employer');
else
App::abort(400);
}
that's it. no need to touch the layout. Avoid putting logics in layout as possible. in longer run, it will be a mess.