Post by thegeekz » Thu Aug 14, 2014 2:50 pm

Hi everyone,

I have a small favour to ask..

As you already know, in Sale > Coupon, there are 2 fields we either leave it blank or enter a number.

This works perfectly -- it defaults to 0 upon saving -- if I leave it blank.
Uses Per Coupon:
The maximum number of times the coupon can be used by any customer. Leave blank for unlimited
Uses Per Customer:
The maximum number of times the coupon can be used by a single customer. Leave blank for unlimited
Problem comes for my Advanced Coupons & Sales Promotion extensions with similar codings for above, but when I tried to edit accordingly, it just literally left the field box blank - without defaulting to 0.

Code: Select all

		if (isset($this->error['uses_customer'])) {
			$this->data['error_uses_customer'] = $this->error['uses_customer'];
		} else {
			$this->data['error_uses_customer'] = '';
		}
		
		if (isset($this->error['uses_total'])) {
			$this->data['error_uses_total'] = $this->error['uses_total'];
		} else {
			$this->data['error_uses_total'] = '';
		}

.
.
.

    		/* Old code 
    		if (isset($this->request->post['uses_total'])) {
      		$this->data['uses_total'] = $this->request->post['uses_total'];
		} elseif (isset($sales_promotion_info)) {
			$this->data['uses_total'] = $sales_promotion_info['uses_total'];
	    	} else {
      			$this->data['uses_total'] = 1;
    		}
    		*/ 
   	
    	
		if (isset($this->request->post['uses_total'])) {
			$this->data['uses_total'] = $this->request->post['uses_total'];
		} elseif (!empty($sales_promotion_info)) {
			$this->data['uses_total'] = $sales_promotion_info['uses_total'];
		} else {
			$this->data['uses_total'] = 1;
		}
  		
  		/* Old code 
    		if (isset($this->request->post['uses_customer'])) {
      		$this->data['uses_customer'] = $this->request->post['uses_customer'];
    		} elseif (isset($sales_promotion_info)) {
			$this->data['uses_customer'] = $sales_promotion_info['uses_customer'];
		} else {
      		$this->data['uses_customer'] = 1;
    		}
    		*/ 
    	
    		if (isset($this->request->post['uses_customer'])) {
			$this->data['uses_customer'] = $this->request->post['uses_customer'];
		} elseif (!empty($sales_promotion_info)) {
			$this->data['uses_customer'] = $sales_promotion_info['uses_customer'];
		} else {
			$this->data['uses_customer'] = 1;
		}
Original code that I have replaced -- I just /* Commented Old code */

Previously there is validation to ensure a number is entered here, have since hidden that code.

Code: Select all

		
/* Removed Code 
		if (!is_numeric($this->request->post['uses_total'])) {
        	$this->error['uses_total'] = $this->language->get('error_uses_total');
      	}
      	
		
		if (!is_numeric($this->request->post['uses_customer'])) {
        	$this->error['uses_customer'] = $this->language->get('error_uses_customer');
      	}
      	
*/ 
Any take on how to solve this?

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Fri Aug 22, 2014 5:42 pm

help anyone?>

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Thu Aug 28, 2014 10:34 am

Anyone can help?

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by SXGuy » Thu Aug 28, 2014 3:47 pm

Code: Select all

 if (!is_numeric($this->request->post['uses_total'])) {
$this->data['uses_total'] = '0';
} 


Do the same for uses_customer

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by thegeekz » Fri Aug 29, 2014 11:41 am

Thank you for your reply.

Tried replacing:

admin/controller/sale/advanced_coupon.php

Code: Select all

		if (!is_numeric($this->request->post['uses_total'])) {
        	$this->error['uses_total'] = $this->language->get('error_uses_total');
      	}
      	
		
		if (!is_numeric($this->request->post['uses_customer'])) {
        	$this->error['uses_customer'] = $this->language->get('error_uses_customer');
      	}
With

Code: Select all

      	      	if (!is_numeric($this->request->post['uses_total'])) {
		$this->data['uses_total'] = '0';
	}
	
		if (!is_numeric($this->request->post['uses_customer'])) {
		$this->data['uses_total'] = '0';
	}
After leaving the field box blank..... save and return.

It still is an empty box, not with '0' inside.

Is this how its supposed to work, by the way?

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by SXGuy » Sat Aug 30, 2014 3:43 pm

The second code section should be

Code: Select all

 if (!is_numeric($this->request->post['uses_customer'])) {
      $this->data['uses_customer'] = '0';
   }


I can't remember if it should save as blank or 0 however you can check the database coupon table and see if it adds a 0 or try to checkout a free product using your coupon a few times and see if it works.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by thegeekz » Tue Sep 02, 2014 5:15 pm

oops... blur me :

Code: Select all

	/* Removed 
		if (!is_numeric($this->request->post['uses_total'])) {
        	$this->error['uses_total'] = $this->language->get('error_uses_total');
      	}
      	
		
		if (!is_numeric($this->request->post['uses_customer'])) {
        	$this->error['uses_customer'] = $this->language->get('error_uses_customer');
      	}
      	
      	*/
      	
      	
      	      	if (!is_numeric($this->request->post['uses_total'])) {
		$this->data['uses_total'] = '0';
	}
	
		if (!is_numeric($this->request->post['uses_customer'])) {
		$this->data['uses_customer'] = '0';
	}


No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am
Who is online

Users browsing this forum: No registered users and 13 guests