Post by kg0925 » Sat Apr 07, 2018 6:56 pm

hello, i am using opencart version 1.5.6.4 i just want to add a function to cod payment mode. if a perticular option's any value selected then cod option should be disappear from checkout page. i am running a women's clothing website where i want to provide stitching service and want this modification. ex. i have a option " Stitching" and their values are M, L, XL if customer select any of values from stitching option then cod must be disabled or hidden from check out page. any one have idea how to do this? i searched for the extension but couldn't find

Newbie

Posts

Joined
Wed Mar 29, 2017 11:09 pm

Post by straightlight » Sat Apr 07, 2018 9:46 pm

According to this topic: https://stackoverflow.com/questions/272 ... p-the-keys , the array_column is meant for PHP 7. The reason why the results may be failing for you is because your server may not be upgraded to PHP 7. Otherwise, you'd need to use the old ways with the array mapping which is no longer necessary with PHP 7.
Last edited by straightlight on Mon Apr 16, 2018 8:55 pm, edited 4 times in total.

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by kg0925 » Mon Apr 09, 2018 2:21 pm

Thanks for your quick reply. the_option_value should i change with option name 'size' or their values like 'M, L , XL, XXL'. i tried both way but it's not working. it's still showing cod option during checkout.

Newbie

Posts

Joined
Wed Mar 29, 2017 11:09 pm

Post by straightlight » Tue Apr 10, 2018 4:21 am

I just realized the status should be set to false. Not true. See if the last part of the instructions works when entering the option value with this:

Code: Select all

} elseif (in_array('the_option_value', $option_values)) {
			$status = false;

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by kg0925 » Tue Apr 10, 2018 1:06 pm

still it's not working. i made this vqmod for this mod

Code: Select all

<modification>
	<id> disable cod for stitching option</id>
	<version>1.1.0</version>
	<vqmver>1.1.0</vqmver>
	<author>custom</author>

	<file name="catalog/model/payment/cod.php file">
		<operation error="skip">
			<search position="before"><![CDATA[if ($this->config->get('cod_total') > 0 && $this->config->get('cod_total') > $total) {]]></search>
			<add><![CDATA[$products = $this->cart->getProducts();
		
		foreach ($products as $product) {
			$option_data = array();

			foreach ($product['option'] as $option) {
				if ($option['type'] != 'file') {
					$value = $option['option_value'];
				} else {
					$filename = $this->encryption->decrypt($option['option_value']);

					$value = utf8_substr($filename, 0, utf8_strrpos($filename, '.'));
				}

				$option_data[] = array(
					'name'  => $option['name'],
					'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value)
				);
			}
		}
		
		$option_values = array_column($option_data, 'value');]]></add>
		</operation>
<operation>
			<search position="before"><![CDATA[} else {
			$status = false;]]></search>
			<add><![CDATA[} elseif (in_array('Stitching', $option_values)) {                      // i also applied option values but not working both way
			$status = false;]]></add>
		</operation>

	</file>
</modification> 
stitching is the option name and their values are M, L , XL i tried with both way option name and their values. also made the status false but still it's not working.

Newbie

Posts

Joined
Wed Mar 29, 2017 11:09 pm

Post by straightlight » Tue Apr 10, 2018 7:36 pm

After creating this XML file, use the VQMod Manager extension from the Marketplace to see if you have any error structure in the XML file itself or having any conflicts.

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by kg0925 » Fri Apr 13, 2018 2:54 pm

i am already using vqmod manager. but it's not showing any kind of error in vqmod manager.

Newbie

Posts

Joined
Wed Mar 29, 2017 11:09 pm

Post by straightlight » Fri Apr 13, 2018 6:46 pm

Is your request about an option value as per your topic title indicates or rather a product option value you are looking for to track?

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by kg0925 » Fri Apr 13, 2018 7:47 pm

option value

Newbie

Posts

Joined
Wed Mar 29, 2017 11:09 pm

Post by straightlight » Fri Apr 13, 2018 7:54 pm

I have now edited the steps above: viewtopic.php?f=22&t=203471&p=720189#p720189 . You were looking to use the option names, not the option values.

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by kg0925 » Fri Apr 13, 2018 11:12 pm

still it's not working. also it's not showing any error in vqmod

Newbie

Posts

Joined
Wed Mar 29, 2017 11:09 pm

Post by straightlight » Fri Apr 13, 2018 11:28 pm

See if there are errors showing in the error logs.

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by kg0925 » Sat Apr 14, 2018 1:39 pm

That is the problem it's not showing any error in vqmod manager and in error logs.

Newbie

Posts

Joined
Wed Mar 29, 2017 11:09 pm

Post by straightlight » Sat Apr 14, 2018 9:50 pm

Clear your OC cache from your system/cache folder (excluding index.html file)

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Mon Apr 16, 2018 8:55 pm

I have now edited the instructions above to upgrade to PHP 7 and pointed out the Stackoverflow topic in the mean time.

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by kg0925 » Wed Apr 18, 2018 8:59 pm

i appreciate your effort and your valuable time to answer this query. my server is running on 5.6.23 php version. and i am not a programmer. i just have some basic knowledge about programming. so i don't know where to change what kind of change i need for array mapping.

Newbie

Posts

Joined
Wed Mar 29, 2017 11:09 pm

Post by straightlight » Thu Apr 19, 2018 8:49 am

Since you're using OC v1.5x releases, it is also quite old. I would suggest to upgrade to at least v2.3.0.2 release for PHP compatibility improvement.

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 11 guests