Post by darth_danny » Tue Aug 16, 2016 7:56 pm

Hi,

I wrote this based on another mod with the intention of removing some checkout fields (address, company, post code & city) and adding my own custom fields (custom field should appear if a specific product is in the shopping cart). I installed it to give it a test but doesnt seem to be working. (I am using OC 2.2.0.0). What could be wrong?

Code: Select all

<modification>
	<id><![CDATA[Remove unwanted checkout fields for opencart]]></id>
	<version><![CDATA[1.0]]></version>
	<opencart><![CDATA[2.2]]></opencart>
	<vqmver><![CDATA[2.4]]></vqmver>
	<author><![CDATA[Darth_D 16/08/2016 ]]></author>
	
	<file path="catalog/controller/checkout/" name="payment_address.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 address_2" error="abort" >
			<search position="replace" offset="2" ><![CDATA[
				if ((utf8_strlen(trim($this->request->post['address_2'])) < 3) || (utf8_strlen(trim($this->request->post['address_2'])) > 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>
		<operation info="Set checkbox Subscribe Newsletter checked default" error="abort" >
			<search position="replace" ><![CDATA[
				$data['newsletter'] = '';
			]]></search>
			<add><![CDATA[
				$data['newsletter'] = '1';
			]]></add>
		</operation>
	</file>

	<file path="catalog/view/theme/*/template/checkout/" name="payment_address.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="col-sm-2 control-label" for="input-fax"><?php echo $entry_fax; ?></label>
			]]></search>
			<add><![CDATA[
				<div class="form-group" style="display:none">
				  <label class="col-sm-2 control-label" for="input-fax"><?php echo $entry_fax; ?></label>
			]]></add>
		</operation>

		<operation info="Default. hide Address block" error="log" >
			<search position="replace" ><![CDATA[
				<fieldset id="address">
			]]></search>
			<add><![CDATA[
				<fieldset id="address" style="display:none">
			]]></add>
		</operation>
	</file>
	
</modification>

New member

Posts

Joined
Wed Jul 27, 2016 5:41 pm

Post by IP_CAM » Wed Aug 17, 2016 9:57 am

whatever you're trying to achieve, by trying to remove/replace a Value, two lines below an Anchor line.
You better declare the Value/Anchor, you want to remove, not something above or below it, if there is a way, to do this., possibly using the INDEX Value as well, if the same 'Anchor' Code exists in multiple Sections.
But I cannot tell, because I don't know, how your source looks.

Code: Select all

<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>
--
or even worse, above the -php telephone- Line, you want to replace something, to add the forrm-group line,
but at the same time, this would result in implementing a second -php telephone- Line above the existing one:

Code: Select all

<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>
---
as I look at it, anyway.
You should therefore clear out / make sure on this OFFSET matter, in the first place, I assume.

Good Luck! ;)
Ernie

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by darth_danny » Wed Aug 17, 2016 5:34 pm

For now I was testing this on the default 2.2.0.0 theme. The view I intend to change is that of the billing details in the checkout. I had based the coding structure this off a free vqmod extension I had installed called quick registration.

New member

Posts

Joined
Wed Jul 27, 2016 5:41 pm

Post by IP_CAM » Thu Aug 18, 2016 1:46 am

But, this LINE does not even exist, in the Default Theme OC v.2.2 ../checkout/payment_address.tpl File:

Code: Select all

<label class="col-sm-2 control-label" for="input-telephone"><?php echo $entry_telephone; ?></label>
so, it's not a valid ANCHOR TAG for a VqMod to function, in the first place.
---
And to remove this:

Code: Select all

if ((utf8_strlen(trim($this->request->post['address_1'])) < 3) || (utf8_strlen(trim($this->request->post['address_1'])) > 128)) {
would not be of help either, since this line is PART of a Multi-Line Routine, therefore not editable by VqMod, in full.

Code: Select all

if ((utf8_strlen(trim($this->request->post['address_1'])) < 3) || (utf8_strlen(trim($this->request->post['address_1'])) > 128)) {
   $json['error']['address_1'] = $this->language->get('error_address_1');
}
resulting in an error, since it leaves a Part of an undefined Code in the file, as well as an OPEN curly end tag:} consequently colliding with other Code.
...
So, you see, it's just not gonna work, as planned ! ;)
You would better hard-code such into the existing Source Files.

Ernie

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by Cue4cheap » Sat Aug 20, 2016 6:09 am

What if you changed error="log" for all?
https://github.com/vqmod/vqmod/wiki/Scripting

Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

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

Hi All,


Thanks for the assist finally got it working :-)

New member

Posts

Joined
Wed Jul 27, 2016 5:41 pm

Post by Cue4cheap » Fri Aug 26, 2016 7:10 am

darth_danny wrote:Hi All,


Thanks for the assist finally got it working :-)
What was the way you found it and fix?

Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by darth_danny » Mon Aug 29, 2016 1:06 pm

the validation script I had in vqmod and that of payment_address.php did not match

New member

Posts

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

Users browsing this forum: No registered users and 10 guests