What virtuemart file to edit when saving order details after purchasing product? - joomla2.5

Do you know what file to edit when you want to save order details in database after purchasing product in virtuemart 2?
I want to save some order details into another table after purchasing. But I don't know what file to modify, I found the controller as well as view files for the cart but can't find the model where the data are inserted to database. We are currently using Joomla 2.5.17 and Virtuemart 2.0.26,

In VM 2.x you can find the related controller as cart.php have a function confirm().
It calls a function from cart helper file. confirmDone() you can add your custom function inside any of these function or directly in order.php model file on admin side.
These function accessing time you will get cart session so all the cart items data will be available inside these functions.
Hope its helps..

Related

Django Admin LogEntry: how it works in non admin actions?

I am having some struggles how does exactly django.admin.LogEntry objects are created.
Consider the following scenario:
I have a bunch of functions which take a csv file with data that allow me to create multiple objects at one call (just iterate through the file, use the data and if data in given row is correct: create a Model instance). I want to make sure that that each of that creation will be logged.
The question is: django docs are not very descriptive on how does LogEntry works and I am not sure if such actions (not taken in the admin panel itself) will be logged there. Also: will the LogEntries be created for the related objects or I have to trigger them manually?
Does anybody got any experience with such scenarios and can share thoughts about it?
The LogEntry model is in the Admin package and only used by Django admin by default. It is used in the admin layer and not model layer when saving objects. if you want to use it outside the admin, then you will have to manually create the entries yourself. That also means the admin will likely display entries of changes made by normal users so you have to think about how you want the entries displayed

Registering a dummy model in Django admin to control multiple models data

Is it possible to register a dummy model (Does not exist in db) that will display data from multiple models in one page?
Maybe just list all objects and when use click on one, a new webpage is opened with details of the clicked on objects? Which is usually this view:
admin:{app_name}/{model_name}/{object_id}/change
The closest standard solution to what you want are Django inlines:
https://docs.djangoproject.com/en/3.0/ref/contrib/admin/#using-generic-relations-as-an-inline
I fail to see how you could create a model not present in the db.

Adding record of page views and details of change to django_admin_log

We are using LogEntry/django_admin_log and recording additions, changes and deletions made from Django Admin. However we have two issues we need to address:
1.) Changes record only the field that changed. Not the old and new values. We would like to add the specific details of all changes.
2.) We would like to record an action in this log every time a page is viewed on the Django Admin panel.
How would it be best to proceed?
We are happy to do some work to extend the existing functionality of this, or we are happy to move to a completely new 3rd part module if necessary, or write our own. But would like some guidance from some experts?
We had similar requirements in terms of keeping history and track of actions done by users with a higher level of detail in terms of values changes. What we ended up doing was creating a new model called "History" which we populated with the user, the name of the model being changed, the instance id and a dictionary called changes showing the name of each field changed and values from - to.
In order to populate the new model, we overrode the save_model function in the admin file for the model we want to track. Regarding the page views, you can overrride the get_fields if "obj" is not None and create an instance of History accordingly.

Retrieve value from database for the particular id which is in url using class based views in django

I need to display value into textbox fields in template page which is get from the database for the particular id. After that i need to edit those details which is needed and to update those values into database.These things are done by function based views easily. But now i want to do that it in class based views.Which view is used to do that. Can anyone help me to do that.
You should use the UpdateView for this task.
UPDATE: If you want to display instance details on one page and the edit form on another then use the DetailView for the first step.

Opencart add coupon code on database through module

I have searched almost all question but didn't get any hint how can i add coupon code from module...?
I have created module and from front side that is 'catalog\controller\module\mycoupon' i want to add coupon code auto on database, for adding i use this code
$this->model_sale_coupon->addCoupon($this->request->post);
but for that i need to load model 'sale/coupon' but which is located in admin controller so how can i call that model into catalog module ?
Or do i need to add that via DB model directly on database?
$this->db->query();
I am getting this error "Notice: Error: Could not load model checkout/cart!" because its outside catalog right how to call that?
My aim is to create coupon code directly on fly when someone click on submit.
Copy the addCoupon method from admin/model/sale/coupon into catalog/model/checkout/cart and then you will be able to call the method from the front side. You may need to adjust the method.
If you don't wish to modify core files, simply create a new model and load that so that your changes won't be overwritten on upgrade.