Please help me to display the coupon code or coupon name in opencart 2.1.0.1 product page. For the promotion of products I need to display the coupons or promo code in the product page of opencart 2.1.0.1.
I think this will be hard coded, you will have to add a method to the copoun model which will take the product_id and return the copouns related to this product_id, then in the product controller you will need to call this method and list the copouns in a data variable, then in the product view you need to show them in the desired place.
Related
I have a model with customers
in my front I have a combobox with the list of my customers.
how I can in djangoadmin hide or show this customers?
I think it could be a checkbox like "this customer is active/inactive"
but how can I solve this with djangoAdmin?
I think it could be a checkbox like "this customer is active/inactive"
but how can I solve this with djangoAdmin?
You can add the field in your customer column called is_active as a boolean field in your model which you can edit from djangoadmin.
I have an OpenCart site and would like to disable the update button in the View Cart page for products belonging to a specific category. If the products don't belong to the category, the update button will be enabled.
You can add a column in the database then add supporting code to the admin/controller, admin/template, catalog/controller, catalog/view/theme/yourtemplate. Then you can wrap the view cart button in your catalog/view/theme/yourtemplate/product/product.tpl with a PHP IF exists statement.
Just an example. Good luck!
I created two models in django. First is about products (name, price etc) and second is shop which contains this products.
How can I edit every product from my shop in one form?
For example i have page with shop detail (all products, prices) and I want on this page edit few prices of products from this shop. I don't want click on every product and edit it, I want do it on one page. Is it possible? What is the best way to do it?
You can use inline forms
# admin.py
class ProductInline(admin.StackedInline):
model = Product
class StoreAdmin(admin.ModelAdmin):
inlines = [ProductInline]
admin.site.register(Store, StoreAdmin)
With this configuration, you will be able to edit / add / delete related Products on the Store admin page.
Solution 1
The Django admin site, acessible at http://<myurl>:<myport>/admin/, will allow you do edit saved model data. Can't remember off the top of my head if you can edit multiples or not though..
Solution 2
Connect to your datasource using a SQL Editor for example, using MySQLWorkbench, and script it, which would allow you to update all the products for one shop in one fell swoop. Some example SQL would be update products set price='4.99' where shop_id=1 or something similar
I have a design with twitter bootstrap front-end and django backend, and I want to make on a shopcart a "plus/minus" button to update quantity and price. How would be the best option to do this?
Currently I am using a form with 2 buttons and updating the quantity and price values within the view. If I use Jscript how can I update the session fields quantiy and price ?
I want to achieve this : http://bootsnipp.com/snippets/featured/buttons-minus-and-plus-in-input but when clicking plus/minus to have price updated according to the quantity values.
Javascript can be used to update the price based on the quantity.
Django only does updates when you submit data to the database. You can make a shopping cart object in the database of coarse and save what the User has selected in that cart. But for updates on the page for the price and quantity without submitting data to the database it would be Javascript.
I recommend using Javascript on the page for price and quantity updates, and then when they select an "add-to-cart" button, then to submit the data like any other Django Form, and save the data in a shopping cart for that User's session.
I think for your situation a simple jquery function for when quantity element is changed will suffice.
for example something like
$(document).ready(function() {
$("#quantity").change(function(){
q = document.getElementById("quantity").val()
p = document.getElementById("price").val()
t = p*q
document.getElementById("total").val(t)
});
});
I want to add, some fields depending on others. I have city and country model. I can include country as foreign key in city model. And then if I will add both city and country in another model ( say content) then will it be just like dependent selectboxes? like cities will be shown based on selected country via ajax? If not then what is correct way? and also is there a way to add city on the spot while adding main content data if city is not already on list?
So are above possible by using django admin or is it that django don't give? If not then how can it be done in django autogenerated admin?
You can do exactly what you ask using django-smart-selects
Hope that helps...
I can include country as foreign key in city model
This seems like a good idea.
And then if I will add both city and country in another model ( say content) then will it be just like dependent selectboxes? like cities will be shown based on selected country via ajax?
No, it will not get filtered automatically, you will need to write that code yourself. Both in admin and on frontend.
and also is there a way to add city on the spot while adding main content data if city is not already on list?
You will get this in the admin area.
Go ahead and start doing it, and when you run into specific problems, post them here if you can't solve it. Also read the Django docs, it is pretty elaborate on the topic of models.