how to add new filed to opencart - opencart

I want to add three more filed to cart page .()
<input name="pr_name">
<input name="pr_phone >
<input name="pr_add">
can any one help me to add these files to cart .

you will need to modify the following:
the model for the cart /catalog/model/checkout
the controller for the cart /catalog/controller/checkout
the view for the cart whatever theme you are using
finally you will need to do the same for the admin panel and depending on where you would like to see them for example you might want to view them in the invoice you will need to change the model / controller that correspond to that. unfortunately its not like a plug and play thing.

Related

Sitecore Rich Text links not user friendly when rendered through Glass

I have a component that includes a single Rich Text field. In the sublayout, the field is rendered as an Html.Editable with Glass so that it can be edited on the page in PageEditor. It looks like this:
public override void Initialize()
{
litBodyContent.Text = Html.Editable(GlassItem, item => item.Body);
}
<div style="min-height: 38px">
<asp:Literal runat="server" ID="litBodyContent" />
</div>
However, when I insert links using the Rich Text editor, when the page is rendered (in normal view after being published, not in page editor), the links are rendered with the item ID rather than the user friendly path, like this:
Go to another page
I am pretty sure that this is an issue with Glass. How can I keep the field editable in the Page Editor but make it render the link correctly?
You can check if you have proper attribute in the model.
If you have SitecoreFieldSettings.RichTextRaw attribute, it will NOT pass through render pipeline and returns the RAW HTML. Instead if you use Default (SitecoreFieldSettings.Default), rich text content will go through render pipeline and url will be in friendly format.
http://docs.glass.lu/html/d44739b2-5f0e-d862-f62c-86c50f0b262f.htm
Can you try to change it from using literal to use Editable() method directly, Something like:
<%= Editable(GlassItem, x => x.Body) %>
I think Initialize() is too soon in the page life cycle. Try moving it further along, like to Page_Load() or so.

Django advanced nesting urls

Welcome,
I've got a problem where I`m trying to make a deep nesting.
The thing is that I have Menu that has SUBMENU that can have multiple categories and those categories can have multiple services available and those services can have multiple products.
Writing urls for that specific thing was easy but when I'm trying to create a product that has no category and I want it to be displayed directly in SUBMENU the problem is with writing url for that specific product that doesnt overlap with SUBMENU slug.
For example:
MENU > SUBMENU1 > CATEGORY 1 > AVAILABLE SERVICES > PRODUCT 1
MENU > SUBMENU2
MENU > SUBMENU3 > PRODUCT 2
all of those names are slugged and my urls.py looks like this:
url(r'^uslugi/(?P<category_slug>\S+)/(?P<services_slug>\S+)/(?P<service>\S+)/$', views.show_service_details, name='show_service_details'),
url(r'^uslugi/(?P<category_slug>\S+)/(?P<services_slug>\S+)/$', views.show_services, name='show_services'),
url(r'^uslugi/(?P<category_slug>\S+)/$', views.show_categories, name='show_categories'),
url(r'^uslugi/(?P<product_slug>\S+)/$', views.show_product_without_cat, name='show_product_without_cat'),
The thing is that when I try to enter a product with no category (just placed in submenu), my urls are calling the show_category view. Changing sequence of those urls won't resolve my problem, because I won't be able to enter my show_categories because django will try to execute show_product_without_cat
I there a reasonable solution for this without redesigning all structure ?
Unfortunetely even saying to django in template to call specific VIEW doesn't help at all. It just goes through all urls and matches the first one
<a href="{% url 'show_product_without_cat' i.url %}" >
<img src="/media/{{ i.image }}"> <br/>
</a>
URL dispatcher finds the first url that matches the request path and calls the found view. You have the same url regex for both show_categories and show_product_without_cat views so only the first occurrence of url will work.
The only solution is to create an intermediate view which will check the slug against Category or Product model and call the appropriate view.
def product_or_category(request, slug):
if Product.objects.filter(slug=slug).exists():
return show_product_without_cat(request, slug)
return show_categories(request, slug)
And assign the url to this view:
url(r'^uslugi/(?P<slug>\S+)/$', views.product_or_category,
name='show_product_or_category'),
But note that with this solution you can't have a category and product with the same slug.

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

adding line breaks and headers in django's admin interface

EDIT: If you are going to give a downvote, at least explain why -.-
Also, read comments if my post is still unclear. I tried to explain it a bit more in the comments but if it is still unclear about what I'm saying, let me know and I will take printscreens and explain using images.
I have created a model like so
class Post(models.Model):
title_of_post = models.CharField(max_length=100)
actual_post = models.TextField()
and I put this model in the admin interface and enabled the admin interface. Now, when I go to 127.0.0.1/admin/ and sign in, I can add this model. The posts created in the Post model can be seen on the homepage (127.0.0.1) so say my "title_of_post" is "title" and my "actual_post" is "the actual post", if I go to 127.0.0.1 I can see both the title and actual post on the homepage. The problem is, when I am in the admin interface and in the actual_post text box / TextField section, suppose I write this.
Something.
else
It would not recognize that I pushed the enter key after the period. I tried
Something. <br>
else
but that also didn't work. It does not go on a new line after the period. Is there any way to go to the next line when inputting information from the text box / TextField in the django admin interface? Is there any way to put headers from the admin interface, not from the template? Essentially, I want to be able to create this html from the admin interface.
<h1>Something.</h1> <br>
else
in order to show html inside a property, you need to place like this in your template:
{{ post.actual_post|safe }}
the safe template filter its good for not escaping html tags inside your template.
And this will print as:
Something
else
intead of:
Something <br /> else

Flickr albums in django admin

I want to do the following:
Having a model (p.e. a model which handles data about photographic reports) create a section which has a preview of an specific flickr album. The URL will be provided by an URLField (until the first save the preview will not be available).
After the first save, it'll show previews of all the images inside that album, and make them selectable (through jQuery for example). Then again, when the images are selected and the object is saved (I think I can use django signals for this) it will notify a specific user telling him a selection has been made.
Is there any plugins available, or any easy way to implement this in django-admin?
Update: 22 days and no anwers... does that mean it can't be done in django-admin?
I personally can't think of any easy way to implement this in the Django admin, simply because I doubt many people who've done it have thought to open source it. I can imagine that it would be very specific to a certain user's / programmer's needs.
In any case, if you wanted to solve this issue, I'd say that your best bet would be overriding the Django admin templates in your django/contrib/admin/templates/admin folder. I believe you'd be best off by editing change_form.html.
My basic approach would be this:
Check the name of the model using opts.verbose_name. For example, if you wanted to do this processing for a model whose verbose name is "Gallery", you would do
{% ifequal opts.verbose_name "Gallery" %}
<!-- neat gallery view -->
{% else %}
<!-- regular form -->
{% endifequal %}
Make a custom template tag that will display the gallery view / form given the object_id and the type of object. This way you can replace the <!-- neat gallery view --> with a {% show_gallery object_id %}. See the Django Docs for more info on creating custom template tags. It's pretty straightforward.
Add whatever Javascript or custom stuff in your template tag template. What you choose to do is up to you.
Sorry you haven't gotten many more answers to your question. Hope this helps!