Magento: How to Add Order / Payment information to Admin-BackEnd - magento

I´ve been able to add a custom field called Bank Name to the credit card payment option which saves into the DB, however I am now trying to display such information on the back-end under Customer > Manage Customer > (Select an customer) > Orders > (Select an Order) and there´s a field called Payment Information which displays the credit card payment info and this is where I want the Bank Name to appear.
I have already tried to edit the following files with no success.
app\design\adminhtml\default\default\template\payment\form\cc.phtml and ccsave.phtml by adding the following.
<div class="input-box">
<label for="<?php echo $_code ?>_cc_bankname><?php echo Mage::helper('payment')->__('Bank Name') ?> <span class="required">*</span></label><br/>
<input type="text" id="<?php echo $_code ?>_cc_bankname" name="payment[cc_bankname]" title="<?php echo Mage::helper('payment')->__('Bank Name') ?>" class="input-text validate-cc-number" value="<?php echo $this->getInfoData('cc_bankname')?>"/>
</div>
but this only enables the option to edit the attribute when manually creating a new order for the customer.
Does anyone know which file should be edited and how? I´ve tried to edit the cc.phtml and ccsave.phtml files under add/design/adminhtml and also under mage but no luck.
Forgot to mention I´m working with Magento 1.7
::::::::::::::::EDIT::::::::::::::::
After further search thru the payment files, I found that there are two files that need to be edited but I still need some help.
I adited \app\code\local\Mage\Payment\Block\Info\cc.phtml by adding two functions to the file.
First a public function
public function getCcBankname()
{
return $this->getInfo()->getCcBankname();
}
Then a protected function
if ($this->getInfo()->getCcBankname()) {
$data[Mage::helper('payment')->__('Bank Name')] = $this->getInfo()->getCcBankname();
}
Then I edited the following file \app\code\local\Mage\Payment\Block\Info\ccsave.phtml by adding this.
$transport = new Varien_Object(array(Mage::helper('payment')->__('Bank Name') => $info->getCcBankname(),));
Now this modifications allowed for the Bank Name to appear on the Backend exactly where I wanted it BUT the problem is that it not populating the data that´s store on the DB.
Anyone knows why it´s not pulling the data from the DB?
:::::::::::::::: EDIT #2 ::::::::::::::::
Well it seems that everything I did worked but there was just one little problem. The bank name data should be set on two different Tables. sales_flat_order_payment and sales_flat_quote_payment but for some reason the data is only saving on sales_flat_quote_payment. I manually entered the data on sales_flat_order_payment and it worked, I was able to visualize the Bank Name on the backend.
Now I have to figure out how to get the data to save on sales_flat_order_payment whenever a payment is processed and why it´s being saved on sales_flat_quote_payment but not on the other.

For the payment method ccsave, the "Payment Information" section of
Customer > Manage Customer > (Select customer) > Orders > (Select Order)
is usually created by the template
app/design/adminhtml/default/default/template/payment/info/default.phtml

Related

Joomla Component - Site Model Issue

I've been developing a Real Estate component for several of my clients. I have most everything working, except getting images from a separate table.
One example of a site model is City. Within the city model, the primary get (query) is a list of properties, based on the city. Example, if from either the cities view, or menu item, a city such as Dallas is selected, then in the single city view only property listings where property city = Dallas will show.
That part is working great, as it is supposed to. The problem is that every listing has multiple images, stored in an images table. On the property list view, only a single image (out of potentially many) needs to be pulled an displayed.
Adding as a "linked" sub-query within the main properties query doesn't work, as it will create multiple duplicate property listings for each image. So, I created as a custom method, get image.
The compiler that I am using to aid in the building doesn't support a signature method (method that takes values), so I needed to add as a class value. In the getItems function for properties, I created the class value of:
$this->a_property_id = $item->id;
Then, in the getImage custom function I added
$query->where('a.propid = ' . $db->quote($this->a_property_id));
as part of the query. In theory, this should pull a single item where a.propid equals the property id, such as property id=3, then pull an item from images where propid=3.
Lastly, I added the image code in the site view default.php as part of the foreach:
<?php foreach ($this->items as $item): ?>
<li>
<div class="uk-grid uk-panel uk-panel-box">
<div class="uk-width-medium-1-3">
<?php if(empty($this->image->path)){ ?>
<div> <img class="uk-thumbnail uk-thumbnail-medium" src="<?php echo JURI::root().'media/com_mostwantedrealestate/images/No_image_available.png'; ?>"> </div>
<?php } else { ?>
<div> <img class="uk-thumbnail uk-thumbnail-medium" src="<?php echo JURI::root() . $this->image->path . $this->image->filename; ?>"></div>
<?php } ?>
</div>
<div class="uk-width-medium-1-3 uk-float-left">
<a href="<?php echo 'index.php?option=com_mostwantedrealestate&view=property&id='.$item->id;?>" title="<?php echo $item->name;?>" rel="" >
<h3><?php echo $item->name; ?></h3>
</a>
</div>
This is kind of working, but not completely, so I'm unsure what I may be missing. With the way I have this coded, it's displaying an image. If there is only a single property listing, then it shows the proper image, however if there a, lets say, two properties: id=1 and id=3, then it shows propid=3 from the image table for both listings, rather than showing propid=1 for id=1 and propid=3 for id=3.
Any thoughts on what I might be missing?
You're looping over the $this->items but you use the same $this->image object for all of them. So you see the same image over and over again.
You can fix this by adding the image information to the item. Since you want to show just one image you can easily do this with single query joining your item table and your image table.
Another way is to combine the necessary data from different queries in your model so you can use something like $item->image->path.

How to add 'Company Name' in customer register and billing info

I've been trying to add 'company name' on customer register and onepage checkout but unsuccessfully so far. I tried https://magento.stackexchange.com/questions/15847/add-company-name-to-billing-shipping-dropdown-in-magento but it didn't help at all.
I can't believe there isn't a simple way of doing that.
The company field is already part of the address entity in Magento, if it isn't showing on register and checkout forms you'll need to update the templates to include it.
I recommend that you look in either the base/default or rwd/default theme and look at:
checkout/onepage/shipping.phtml
persistent/customer/form/register.phtml
persistent/checkout/onepage/billing.phtml
You should see company in there and can copy that into your active theme.
Hope that helps!
Adding a new field to Magento new customer registration can be done in 4 simple steps. Follow the steps given below to get done with it.
Step 1: We have to add php and .html form elements that are necessary to create new input boxes for each additional field in register.phtml.
<div class="input-box">
<label for=”company_name”><?php echo $this->__('Company Name') ?></label><br/>
<input type="text" name="company_name" id="company_name" value="<?php echo $this->htmlEscape($this->getFormData()->getCompany()) ?>" title="<?php echo $this->__('Company Name') ?>" class="input-text" />
</div>
Step 2: We need to add elements under “getDefaultEntities()” in Setup.php (path: /app/code/core/Mage/Customer/Model/Entity/), one for each additional field created above:
company_name' => array(
'label' => 'Company Name',
'required' => false,
'sort_order' => 64,
),
Step 3: Add to the content of $customer in AccountController.php (path: /app/code/core/Mage/Customer/controllers/) by grabbing the new fields from posted info, in the createPostAction() function:
$customer = Mage::getModel('customer/customer')->
setCompany($this->getRequest()->getPost('company_name'));
Step 4: Finally, we will need to add database records to table eav_attribute, corresponding to the newly created fields. The idea is to add to the associated data model, where newly defined model data is entered as the “attribute_code”, with the corresponding entity_type_id (which for this data happens to be ‘1’).
Using your favourite SQL editor (i.e. phpMySQL or sqlYog — highly recommended), execute the following SQL statement for each field created above (replacing ‘company’ and ‘Company Name’ with the respective field name information as required):
INSERT INTO eav_attribute (entity_type_id, attribute_code, backend_type, frontend_input, frontend_label, is_global,is_visible, is_required, is_configurable, is_filterable_in_search) VALUES(’1′, ‘company’, ‘varchar’, ‘text’, ‘Company Name’, ’1′, ’1′, ’0′, ’1′, ’1′);

adding a different customer example:seller through a different regestration page

I am using magento 1.9. I want to add a customer group as seller from the front end using a different registration form keeping the registration form for registration of general category separate.
Add in your registration the following field,
<?php
$groups = Mage::helper('customer')->getGroups()->toOptionArray();
foreach ($groups as $group){
echo '<input type="radio" name="group_id" value="'.$group['value'].'" class="validate-radio" >'.$group['label'].'</input><br/>';
}
?>
And save the fields as following in your controller file.
$customer->setGroupId($this->getRequest()->getPost(‘group_id’));

Magento: Inventory increment qty attribute per store

I have one simple question.
My problem is:
Is there are any free extensions that could turn "Enable Qty Increments" and "Qty Increments" from global scope to store view?
Also I have found this question inventory settings
It's have some kind of answer, but I need to confirm this.
If there are no free extension that could fulfill my needs, do I need to write my own extension (as answer in previous link says) or there is an easy way to change scope from global to store view. ?
My Magento version is CE 1.9.1.0
What you could do to achieve the same thing is create a new product text attribute called pack_size, give it a per store view scope, then set the order quantity against it per product, per store view.
Then, in your addtocart.phtml file, here;
app/design/frontend/XXX/YYY/template/catalog/product/view/addtocart.phtml
Where XXX YYY is the name of your theme, and replace the quantity input box with;
<?php $pack = $_product->getData('pack_size'); ?>
<?php if(($pack == 1) || (!$pack)) { ?>
<input type="text" name="qty" id="qty" maxlength="4" value="1" />
<?php } else { ?>
<select name="qty" id="qty" maxlength="12">
<?php
$countme = 1;
while ($countme < 101) {
echo '<option value="'.($pack*$countme).'">'.($pack*$countme).'</option>';
$countme++; } ?>
</select>
Now if the value of pack_offer is set and greater than 1, the user will only be able to choose a multiple of that qty.
Depending on your theme, you may also need to implement this in the cart page.

Magento: Limit Product Max Quantity Per Customer (NOT per Order)

I know we can easily limit the max quantity of a given product a customer can purchase per order, but is it possible (natively or even with a plugin) to limit max quantity of a given product per CUSTOMER ??
I don't want to use a coupon nor modify the code: it needs to be a sale price with the help of native or extension functionality.
Magento 1.5.1
It is not possible native, but you can make a module that will perform such restrictions.
You need to create a resource model, that will retrieve not canceled and not refunded orders for product(s) with particular product id. Actually it just a simple select to sales/order and sales/order_item table. Method of resource model might look like the following:
public function getPurchasedProductQty(array $productIds, $customerId)
{
$select = $this->_getReadAdapter()->select();
$select
->from(array('order_item' => $this->getTable('sales/order_item')),
array(
'qty' => new Zend_Db_Expr('order_item.ordered_qty - order_item.canceled_qty - order_item.refunded_qty'),
'product_id'))
// Joining order to retrieve info about item and filter out canceled or refunded orders
->join(array('order' => $this->getTable('sales/order')),
'order.entity_id = order_item.order_id',
array())
// Limit it to the current customer
->where('order.customer_id = ?', $customerId)
// Filter out refunded and canceled orders
->where('order.state NOT IN(?)', array(
Mage_Sales_Model_Order::STATE_CLOSED,
Mage_Sales_Model_Order::STATE_CANCELED
))
// Add Product Id Condition
->where('order_item.product_id IN(?)', $productIds);
return $this->_getReadAdapter()->fetchCol($select);
}
Then when you observe sales_quote_item_collection_products_after_load event you just can place your custom logic with checking the restrictions on products that are going to be used in the cart and remove that ones from loaded collection. This logic you should implement yourself.
Assuming that you are trying limit the product qty a registered customer who is currently log in can add to their cart.
(This is a one to one relationship, but could easily modify to accomodate many different products and qty per customer)
Create a custom module that will add a field in customer entity, so admin can set the appropriate qty for each customer.
Field name: [ModuleName]_product_id (see Adding attributes to customer entity)
Field name: [ModuleName]_max_cart_qty (see Adding attributes to customer entity)
In (copy files below to your local template folder) and update the qty input field.
/app/design/frontend/base/default/template/catalog/product/view/addtocart.phtml
/app/design/frontend/base/default/template/checkout/cart/item/default.phtml
Change
<input type="text" class="input-text qty" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" />
to (Add a validation class to make sure the qty is less than or equal )
$addValidationClass = '';
if( Customer is login && ModuleName_product_id == $_product->getId() && [ModuleName]_max_cart_qty > 0){
$addValidationClass = ' validate-digits-range-1-' . [ModuleName]_max_cart_qty
}
<input type="text" class="input-text qty<?php echo $addValidationClass; ?>" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" />
If you want to do server-side validation then create a observer for add to cart event, that compare the above logic to the item currently been add to cart
Below Extension Will Be help to achieve this
https://www.magentocommerce.com/magento-connect/maximum-order-quantity.html
Edit
In this Extension give
Quite often store owners need to restrict the order product quantity with custom message at cart page. This is not possible while using the default admin settings. However, by using this extension you can set the limit for product quantity with custom error message. If maximum quantity limit exceeds the limit then error message will be shown at cart page.
You can set the maximum quantity for each product with custom error message. You can enable/disable globally them using the backend options.

Resources