TIP: Enabling coupon field in Admin panel when editing orders

There doesn’t seem to be a place to add coupon code when editing orders.



Pain in the butt when customers forget to enter the coupon code and bug you about it.



Here’s how to enable coupon code field.



1. Modify totals.tpl



path: skins/basic/admin/views/order_management/totals.tpl



change:


	{if !$cart.order_id}<br />
	<div class="form-field"><br />
		<label for="coupon_code">{$lang.discount_coupon_code}:</label><br />
		<input type="text" name="coupon_code" id="coupon_code" class="input-text-large" size="30" value="" /><br />
	</div><br />
	{/if}<br />

```<br />
<br />
to:<br />
<br />
```php
	{if $cart.order_id}<br />
	<div class="form-field"><br />
		<label for="coupon_code">{$lang.discount_coupon_code}:</label><br />
		<input type="text" name="coupon_code" id="coupon_code" class="input-text-large" size="30" value="" /><br />
	</div><br />
	{/if}<br />

```<br />
<br />
<br />
The above will show the coupon code field in the step 3 of 'edit order'.<br />
<br />
<br />
[B]2. Modify order_management.php<br />
[/B]<br />
path: controllers/admin/order_management.php<br />
<br />
<br />
Change:<br />
<br />
```php
		// Apply coupon<br />
		if (!empty($_REQUEST['coupon_code'])) {<br />
			$cart['pending_coupon'] = $_REQUEST['coupon_code'];<br />
		}<br />

```<br />
<br />
To:<br />
<br />
```php
		// Apply coupon<br />
		if (!empty($_REQUEST['coupon_code'])) {<br />
			$cart['pending_coupon'] = $_REQUEST['coupon_code'];<br />
			$cart['recalculate'] = true;<br />
		}<br />

```<br />
<br />
<br />
[B]3. Modify fn.cart.php<br />
[/B]<br />
path: core/fn.cart.php<br />
<br />
Change:<br />
<br />
```php
		// Apply cart promotions<br />
		if ($apply_cart_promotions == true && $cart['subtotal'] > 0 && empty($cart['order_id'])) {<br />
			fn_promotion_apply('cart', $cart, $auth, $cart_products);<br />
		}<br />

```<br />
<br />
To:<br />
<br />
```php
		// Apply cart promotions<br />
		if ($apply_cart_promotions == true && $cart['subtotal'] > 0) {<br />
			if ( (AREA == 'A') || empty($cart['order_id']) ) {<br />
				fn_promotion_apply('cart', $cart, $auth, $cart_products);<br />
			}<br />
		}<br />

```<br />
<br />
The above will apply promotions if the AREA is in the admin or if there is no order_id.

Gonna try this out - give you feedback as soon as I can. Thanks!

just wanted to say thanks and let people know that this fix works awesome.



so dumb that it was left out of 2.x! So important.



thanks again,



Steve

hello



I have added a cupon but i can not remove it from the order. Any help



Thanks

Thanks



Great mod, it realy should come with cs-cart

[quote name=‘dioskouros’]Thanks



Great mod, it realy should come with cs-cart[/QUOTE]



I agreed. This is why they choose not to include …


[QUOTE]The field for entering a coupon code is disabled while editing an order because discounts are already calculated and results are saved in the order and it is quite difficult to imagine how a coupon should be applied. It is necessary to recalculate all discounts over again and this can cause a problem if promotions were removed or they just expired, also the administrator can change the amount of discounts in an order manually.

So, due to the fact that the administrator is able to edit discounts manually, the ability of applying a coupon while editing an order is not provided for in the default functionality.[/QUOTE]