Post by nytrous » Fri Dec 09, 2011 6:40 am

Since this Vqmod is out i was using it on all my themes untill i install the shoppica and this Vqmod simple stoped work!
so i tryed the shoppica forums for help and the only thing they told me was:
"Hi,
We’ve customized the checkout markup and maybe, this is the reason, the extensions does not work.
You will need to manually insert the html code. Hope, there is a guide from the extension creator, how to do this.
Best,
ThemeBurn team"
Great help for a paid theme ??? :|

therefor i had to make this work and create this Mod:
this is fully functional on my shop and hope that help you too!
just replace your code in:

catalog/controller/checkout/payment.php

Code: Select all

<?php  

class ControllerCheckoutPayment extends Controller {

  	public function index() {

		$this->language->load('checkout/checkout');

		

		$json = array();

		

		$this->load->model('account/address');

		

		if ($this->customer->isLogged()) {

			$payment_address = $this->model_account_address->getAddress($this->session->data['payment_address_id']);		

		} elseif (isset($this->session->data['guest'])) {

			$payment_address = $this->session->data['guest']['payment'];

		}	

		

		if (!isset($payment_address)) {

			$json['redirect'] = $this->url->link('checkout/checkout', '', 'SSL');

		}			

			

		if ((!$this->cart->hasProducts() && (!isset($this->session->data['vouchers']) || !$this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) {

			$json['redirect'] = $this->url->link('checkout/cart');				

		}	

									

		if ($this->request->server['REQUEST_METHOD'] == 'POST') {

			if (!$json) {

				if (!isset($this->request->post['payment_method'])) {

					$json['error']['warning'] = $this->language->get('error_payment');

				} else {

					if (!isset($this->session->data['payment_methods'][$this->request->post['payment_method']])) {

						$json['error']['warning'] = $this->language->get('error_payment');

					}

				}	

								

				if ($this->config->get('config_checkout_id')) {

					$this->load->model('catalog/information');

					

					$information_info = $this->model_catalog_information->getInformation($this->config->get('config_checkout_id'));

					

					if ($information_info && !isset($this->request->post['agree'])) {

						$json['error']['warning'] = sprintf($this->language->get('error_agree'), $information_info['title']);

					}

				}			

			}

			

			if (!$json) {

				$this->session->data['payment_method'] = $this->session->data['payment_methods'][$this->request->post['payment_method']];

			  

				$this->session->data['comment'] = strip_tags($this->request->post['comment']);

			}

		} else {

			if (!isset($this->session->data['payment_methods'])) {

				// Calculate Totals

				$total_data = array();					

				$total = 0;

				$taxes = $this->cart->getTaxes();

				

				$this->load->model('setting/extension');

				

				$sort_order = array(); 

				

				$results = $this->model_setting_extension->getExtensions('total');

				

				foreach ($results as $key => $value) {

					$sort_order[$key] = $this->config->get($value['code'] . '_sort_order');

				}

				

				array_multisort($sort_order, SORT_ASC, $results);

				

				foreach ($results as $result) {

					if ($this->config->get($result['code'] . '_status')) {

						$this->load->model('total/' . $result['code']);

			

						$this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);

					}

				}

				

				// Payment Methods

				$method_data = array();

				

				$this->load->model('setting/extension');

				

				$results = $this->model_setting_extension->getExtensions('payment');

		

				foreach ($results as $result) {

					if ($this->config->get($result['code'] . '_status')) {

						$this->load->model('payment/' . $result['code']);

						

						$method = $this->{'model_payment_' . $result['code']}->getMethod($payment_address, $total); 

						

						if ($method) {

							$method_data[$result['code']] = $method;

						}

					}

				}

							 

				$sort_order = array(); 

			  

				foreach ($method_data as $key => $value) {

					$sort_order[$key] = $value['sort_order'];

				}

		

				array_multisort($sort_order, SORT_ASC, $method_data);			

				

				$this->session->data['payment_methods'] = $method_data;			

			}			

			

			$this->data['text_payment_method'] = $this->language->get('text_payment_method');

			$this->data['text_comments'] = $this->language->get('text_comments');

	    $this->data['entry_payment_coupon'] = $this->language->get('entry_payment_coupon');
		$this->data['text_payment_coupon'] = $this->language->get('text_payment_coupon');
		$this->data['text_payment_coupon_success'] = $this->language->get('text_payment_coupon_success');
		$this->data['button_coupon'] = $this->language->get('button_coupon');

			$this->data['button_continue'] = $this->language->get('button_continue');

	   

			if (isset($this->session->data['payment_methods']) && !$this->session->data['payment_methods']) {

				$this->data['error_warning'] = sprintf($this->language->get('error_no_payment'), $this->url->link('information/contact'));

			} else {

				$this->data['error_warning'] = '';

			}	

	

			if (isset($this->session->data['payment_methods'])) {

				$this->data['payment_methods'] = $this->session->data['payment_methods']; 

			} else {

				$this->data['payment_methods'] = array();

			}

		  

			if (isset($this->session->data['payment_method']['code'])) {

				$this->data['code'] = $this->session->data['payment_method']['code'];

			} else {

				$this->data['code'] = '';

			}

			

			if (isset($this->session->data['comment'])) {

				$this->data['comment'] = $this->session->data['comment'];

			} else {

				$this->data['comment'] = '';

			}

			

			if ($this->config->get('config_checkout_id')) {

				$this->load->model('catalog/information');

				

				$information_info = $this->model_catalog_information->getInformation($this->config->get('config_checkout_id'));

				

				if ($information_info) {

					$this->data['text_agree'] = sprintf($this->language->get('text_agree'), $this->url->link('information/information/info', 'information_id=' . $this->config->get('config_checkout_id'), 'SSL'), $information_info['title'], $information_info['title']);

				} else {

					$this->data['text_agree'] = '';

				}

			} else {

				$this->data['text_agree'] = '';

			}

			

			if (isset($this->session->data['agree'])) { 

				$this->data['agree'] = $this->session->data['agree'];

			} else {

				$this->data['agree'] = '';

			}

			

			if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/checkout/payment.tpl')) {

				$this->template = $this->config->get('config_template') . '/template/checkout/payment.tpl';

			} else {

				$this->template = 'default/template/checkout/payment.tpl';

			}

					

			$json['output'] = $this->render();	

		}

		

		$this->response->setOutput(json_encode($json));

  	}

}

?>
in catalog/language/english/checkout/checkout.php :
Find:

Code: Select all

'$_['text_comments'] = 
and in the line after paste:

Code: Select all

$_['entry_payment_coupon']           = 'Enter your code (if available) and click "Apply Coupon"';
$_['text_payment_coupon']            = 'Discount Coupon Code:';
$_['text_payment_coupon_success']    = 'Your discount coupon has been successfuly applied to your order. You will see it in the next checkout step';
$_['button_coupon']                  = 'Apply Coupon';
just replace your code in catalog/view/theme/shoppica/template/checkout/payment.tpl for:

Code: Select all

<?php if ($error_warning): ?>
  <div class="s_server_msg s_msg_red"><p><?php echo $error_warning; ?></p></div>
  <?php endif; ?>

  <?php if ($payment_methods): ?>
  <p><?php echo $text_payment_method; ?></p>
  <div class="s_row_3 clearfix">
    <?php foreach ($payment_methods as $payment_method): ?>
    <?php if ($payment_method['code'] == $code || !$code): ?>
    <label class="s_radio" for="<?php echo $payment_method['code']; ?>">
      <?php $code = $payment_method['code']; ?>
      <input type="radio" name="payment_method" value="<?php echo $payment_method['code']; ?>" id="<?php echo $payment_method['code']; ?>" checked="checked" />
      <strong><?php echo $payment_method['title']; ?></strong>
    </label>
    <?php else: ?>
    <label class="s_radio" for="<?php echo $payment_method['code']; ?>">
      <input type="radio" name="payment_method" value="<?php echo $payment_method['code']; ?>" id="<?php echo $payment_method['code']; ?>" />
      <strong><?php echo $payment_method['title']; ?></strong>
    </label>
    <?php endif; ?>
    <?php endforeach; ?>
  </div>
  <?php endif; ?>

  <span class="clear border_eee"></span>
  <br />

  <h2><?php echo $text_comments; ?></h2>
  <div class="s_row_3 clearfix">
    <textarea name="comment" rows="8" style="width: 99%;"><?php echo $comment; ?></textarea>
  </div>
<div id="coupon">
  <b><?php echo $entry_payment_coupon; ?></b><br /><br />
  <?php echo $text_payment_coupon; ?>&nbsp;
  <input type="text" name="coupon" value="" />
  &nbsp;<a id="button-coupon" class="button"><span><?php echo $button_coupon; ?></span></a></div><br />
</div>

<script type="text/javascript">
$('#button-coupon').bind('click', function() {
	$.ajax({
		type: 'POST',
		url: 'index.php?route=total/coupon/calculate',
		data: $('#coupon :input'),
		dataType: 'json',		
		beforeSend: function() {
			$('#button-coupon').attr('disabled', true);
			$('#button-coupon').after('<span class="wait">&nbsp;<img src="catalog/view/theme/shoppica/image/loading.gif" alt="" /></span>');
		},
		complete: function() {
			$('#button-coupon').attr('disabled', false);
			$('.wait').remove();
		},		
		success: function(json) {
			if (json['error']) {
				alert( json['error'] );
			} else {
				$("input[name=coupon]").val("");
				alert( "<?php echo $text_payment_coupon_success; ?>" );
			}
		}
	});
});
</script>

  <?php if ($text_agree): ?>
  <div class="s_row_3 clearfix">
    <?php if ($agree): ?>
    <label class="s_checkbox"><input type="checkbox" name="agree" value="1" checked="checked" /> <?php echo $this->document->shoppica_text_agree_checkout; ?></label>
    <?php else: ?>
    <label class="s_checkbox"><input type="checkbox" name="agree" value="1" /> <?php echo $this->document->shoppica_text_agree_checkout; ?></label>
    <?php endif; ?>
  </div>

  <span class="s_mb_20 clear border_eee"></span>
  <?php endif; ?>

  <div class="s_submit clearfix">
    <a id="button-payment" class="s_button_1 s_main_color_bgr"><span class="s_text"><?php echo $button_continue; ?></span></a></td>
  </div>


  <script type="text/javascript">
    jQuery( function($) {
      $("a[rel^='prettyPhoto']").prettyPhoto({
        theme: 'light_square', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
        opacity: 0.5,
        social_tools: "",
        deeplinking: false
      });
    });
  </script>
Hope this helps you too
Sorry the bad english!
Thanks kind regards David Sousa

Image


New member

Posts

Joined
Tue Oct 25, 2011 2:24 am

Post by Klimskady » Thu Jan 05, 2012 8:06 am

Thank you so much! I have been struggling with this for far too long, this has worked perfectly....

Active Member

Posts

Joined
Tue Jun 07, 2011 7:57 am

Post by 3antz » Thu Jan 05, 2012 8:49 am

Thank you for the mod !

Active Member

Posts

Joined
Sun Oct 02, 2011 6:52 pm

Post by thepaladin » Thu Apr 19, 2012 11:49 pm

this work in standard Opencart 1.5.2.1. ??
thx

User avatar
Newbie

Posts

Joined
Thu Apr 19, 2012 11:44 pm
Location - Italy

Post by Klimskady » Wed Apr 25, 2012 8:39 am

I haven't tested so far as trying to convert this back to vQmod, I would suggest if you want to test it, rename the Payment.php as Paymentold.php and copy the code above to a new file and save as payment.php in catalog/controller/checkout along with original file and then again rename checkout.php to checkoutold.php in and save the code from the original file and copying the code for that file above, then do the same for payment.tpl just rename it paymentold.tpl and copy the code above into the new file to go in catalog/view/theme/shoppica/template/checkout/payment.tpl.

That way you can test if the changes work and have the original files to revert back to if you need too, just remove the old and save and it will revert over the newer files changed.

I know this was a bit long winded but I hope it helps others in changing code and having the originals there to fall back to if problems occur.

Active Member

Posts

Joined
Tue Jun 07, 2011 7:57 am

Post by 2nevergiveup » Sat Nov 10, 2012 8:25 am

Thank you so much for sharing this with us!

Have you upgraded to Shoppica2 ?
I think the templates are slightly different, there are no payment.tpl or payment.php
If you happen to have the new codes, please share! Thank you!

Newbie

Posts

Joined
Wed Jul 06, 2011 3:12 pm

Post by gpsyroxy » Sat Nov 24, 2012 11:38 pm

Thank you Nytrous,
Do you have any solution for Shoppica 2?

Newbie

Posts

Joined
Sat Nov 24, 2012 11:23 pm

Post by samdz » Thu Nov 29, 2012 2:55 am

Hi;

For guys search to apply coupon code during checkout using the theme Shoppica2

Try this modification or extension, it is for free.

http://www.opencart.com/index.php?route ... on_id=9519

It support Shoppica2.

Sam

Active Member

Posts

Joined
Fri Jan 28, 2011 3:02 am

Post by gpsyroxy » Sun Dec 09, 2012 3:46 am

Thank you. It works.

Newbie

Posts

Joined
Sat Nov 24, 2012 11:23 pm
Who is online

Users browsing this forum: No registered users and 44 guests