The shop I am working on has multiple warehouses where client can pick up an order.
So what I have until now:
In the oxid admin I created an option for pickup. I changed its ID to something more readable in the oxpayments table.
I’ve created a table where I put warehouse names and IDs.
I’ve added a field in oxorder table where I will reference the warehouse ID.
I’ve identified that I need to modify things in the views/azure/tpl/page/checkout/payment.tpl
In payment.tpl when shipping cost is 0 I will display my template to show the select with the warehouse possibilites.
So in the module I created mymodule/models/orderCollect.php
and mymodule/views/elo_payment_collect.tpl
So here are my questions:
In the model, I think I need to subclass oxorder because when in the template someone selects a warehouse I need to save that value in the current order. Is that correct?
If I create a controller as well, how do I instantiate my extended order class keeping the current order in it so that I can save data with the correct order?
Or can I get the current order from the payment subclassed controller?
Also what would be the correct folder structure of the module? The tutorials that are about extending shop functions are on the outdated so its hard to understand with the new file structure.
[QUOTE=greg767;133339]Also what would be the correct folder structure of the module? The tutorials that are about extending shop functions are on the outdated so its hard to understand with the new file structure.
[/QUOTE]
Okay, so really specifically.
I am in the checkout phase when selecting shipping method.
So when instead of shipping, collect from warehouse is selected I want to display a select where I can set a wareahouse and when this is selected I need to put the ID of the warehouse in the current order. That is a field in the oxorder table in database.
To be able to do this I’d need to get the current oxorder object so that I can save this info.
So basically the question is how do I get the current oxorder object? What do I need to subclass?
If I call oxNew(‘oxorder’) I guess it will create a new instance but I still won’t have access to the one that is used at the moment.
I see one problem with my idea, that is the order is not in the database until it is confirmed by the user and since I am at the payment step it won’t work.
So probably I’d need to subclass oxorder, save the warehouse ID in this subclassed object and by extending the save method save this ID in the database after the order is saved.
So could I get the current oxOrder object like this: oxRegistry::get(“oxOrder”)
This way you only get singleton instances, but i think you do not need to get the current oxOrder object yourself. You can store the value in Session during checkout and then override oxorder::finalize to store the value in order object. Look in oxorder::finalize to see how other values get into the order object:
// copies user info
$this->_setUser( $oUser );
// copies basket info
$this->_loadFromBasket( $oBasket );
// payment information
$oUserPayment = $this->_setPayment( $oBasket->getPaymentId() );