Post by darth_danny » Mon Aug 22, 2016 5:34 pm

hi

I am using this code to display input fields (in the template file) depending on the products in the cart with VQmod. Unfortunately I keep getting an errors
Notice:Undefined property: Template\Basic::$model_checkout_order


and
Fatal error: Call to a member function getOrder() on null

Code: Select all

<modification>
	<id><![CDATA[Remove unwanted guest checkout fields for opencart]]></id>
	<version><![CDATA[1.0]]></version>
	<opencart><![CDATA[2.2]]></opencart>
	<vqmver><![CDATA[2.6]]></vqmver>
	<author><![CDATA[Daniel 16/08/2016 ]]></author>
	
	<file path="catalog/controller/checkout/" name="guest.php">
		<operation info="remove validate of address_1" error="abort" >
			<search position="replace" offset="2" ><![CDATA[
				if ((utf8_strlen(trim($this->request->post['address_1'])) < 3) || (utf8_strlen(trim($this->request->post['address_1'])) > 128)) {
			]]></search>
			<add><![CDATA[
			]]></add>
		</operation>
		<operation info="remove validate of city" error="abort" >
			<search position="replace" offset="2" ><![CDATA[
				if ((utf8_strlen(trim($this->request->post['city'])) < 2) || (utf8_strlen(trim($this->request->post['city'])) > 128)) {
			]]></search>
			<add><![CDATA[
			]]></add>
		</operation>
		<operation info="remove validate of postcode" error="abort" >
			<search position="replace" offset="2" ><![CDATA[
				if ($country_info && $country_info['postcode_required'] && (utf8_strlen(trim($this->request->post['postcode'])) < 2 || utf8_strlen(trim($this->request->post['postcode'])) > 10)) {
			]]></search>
			<add><![CDATA[
			]]></add>
		</operation>
	</file>

	<file path="catalog/view/theme/default/template/checkout/" name="guest.tpl">
		<operation info="Default. telephone fields" error="log">
			<search position="replace" offset="-1" ><![CDATA[
				<label class="col-sm-2 control-label" for="input-telephone"><?php echo $entry_telephone; ?></label>
			]]></search>
			<add><![CDATA[
				  <div class="form-group">
					<label class="col-sm-2 control-label" for="input-telephone"><?php echo $entry_telephone; ?></label>
			]]></add>
		</operation>
		<operation info="Default. Hide fax" error="log">
			<search position="replace" offset="-1" ><![CDATA[
				<label class="control-label" for="input-payment-fax"><?php echo $entry_fax; ?></label>
			]]></search>
			<add><![CDATA[
				<div class="form-group" style="display:none">
				  <label class="control-label" for="input-payment-fax"><?php echo $entry_fax; ?></label>
			]]></add>
		</operation>
		<operation info="Default. hide Address block fields" error="log" >
			<search position="replace" offset="19"><![CDATA[
				<label class="control-label" for="input-payment-company"><?php echo $entry_company; ?></label>
			]]></search>
			<add><![CDATA[
                <?php

                    $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);

                    if ($order_info) {

                            foreach ($this->cart->getProducts() as $product) {
                            $option_data = array();

                            foreach ($product['option'] as $option) {
                                if ($option['type'] != 'file') {
                                    $value = $option['value'];
                                } else {
                                    $upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
                                    
                                    if ($upload_info) {
                                        $value = $upload_info['name'];
                                    } else {
                                        $value = '';
                                    }
                                }

                                $option_data[] = array(
                                    'name'  => $option['name'],
                                    'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value)
                                );
                            }

                            $data['products'][] = array(
                                'name'     => htmlspecialchars($product['name']),
                                'model'    => htmlspecialchars($product['model']),
                                'price'    => $this->currency->format($product['price'], $order_info['currency_code'], false, false),
                                'quantity' => $product['quantity'],
                                'option'   => $option_data,
                                'weight'   => $product['weight']
                            );
                        }
                    }

                    foreach($data['products'] as $key => $value)
                    {
                        if($value == "test1")
                        { ?>
                           
                           <div id="payment-custom-field5" class="form-group-custom-field" data-sort="1" style="display: block;">
                                <label class="control-label" for="input-payment-custom-field5">test1</label>
                                <input type="text" name="custom_field[address][5]" value="test1 SUBSCRIPTION" placeholder="test1" id="payment-custom-field5" class="form-control">
                           </div>
                      <?php }
                        elseif($value == "test2")
                        {  ?>
                        
                           <div id="payment-custom-field6" class="form-group-custom-field" data-sort="2" style="display: block;">
                               <label class="control-label" for="input-payment-custom-field6">test2</label>
                               <input type="text" name="custom_field[address][6]" value="test2" SUBSCRIPTION" placeholder="test2" id="payment-custom-field6" class="form-control">
                           </div>
                       <?php }
                    } 
                    ?>
			]]></add>
		</operation>
	</file>
	
</modification>

New member

Posts

Joined
Wed Jul 27, 2016 5:41 pm
Who is online

Users browsing this forum: No registered users and 3 guests