Post by moshair » Fri Apr 03, 2020 5:39 pm

straightlight wrote:
Fri Apr 03, 2020 6:51 am
Take note that adding custom fields into the invoice may result dealing with split invoice template between pages. Only use the following if considering to use split pages if you cannot configure your printer driver to a fit landscape.

In admin/controller/sale/order.php file, in the invoice() method,

find:

Code: Select all

foreach ($orders as $order_id) {
add above:

Code: Select all

$this->load->model('customer/custom_field');
Then, find - still in the invoice() method:

Code: Select all

$data['orders'][] = array(
add above:

Code: Select all

$account_custom_fields = array();

				$filter_data = array(
					'sort'  => 'cf.sort_order',
					'order' => 'ASC'
				);

				$custom_fields = $this->model_customer_custom_field->getCustomFields($filter_data);

				foreach ($custom_fields as $custom_field) {
					if ($custom_field['location'] == 'account' && isset($order_info['custom_field'][$custom_field['custom_field_id']])) {
						if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio') {
							$custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($order_info['custom_field'][$custom_field['custom_field_id']]);

							if ($custom_field_value_info) {
								$account_custom_fields[] = array(
									'name'  => $custom_field['name'],
									'value' => $custom_field_value_info['name']
								);
							}
						}

						if ($custom_field['type'] == 'checkbox' && is_array($order_info['custom_field'][$custom_field['custom_field_id']])) {
							foreach ($order_info['custom_field'][$custom_field['custom_field_id']] as $custom_field_value_id) {
								$custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($custom_field_value_id);

								if ($custom_field_value_info) {
									$account_custom_fields[] = array(
										'name'  => $custom_field['name'],
										'value' => $custom_field_value_info['name']
									);
								}
							}
						}

						if ($custom_field['type'] == 'text' || $custom_field['type'] == 'textarea' || $custom_field['type'] == 'file' || $custom_field['type'] == 'date' || $custom_field['type'] == 'datetime' || $custom_field['type'] == 'time') {
							$account_custom_fields[] = array(
								'name'  => $custom_field['name'],
								'value' => $order_info['custom_field'][$custom_field['custom_field_id']]
							);
						}

						if ($custom_field['type'] == 'file') {
							$upload_info = $this->model_tool_upload->getUploadByCode($order_info['custom_field'][$custom_field['custom_field_id']]);

							if ($upload_info) {
								$account_custom_fields[] = array(
									'name'  => $custom_field['name'],
									'value' => $upload_info['name']
								);
							}
						}
					}
				}

				// Custom fields
				$payment_custom_fields = array();

				foreach ($custom_fields as $custom_field) {
					if ($custom_field['location'] == 'address' && isset($order_info['payment_custom_field'][$custom_field['custom_field_id']])) {
						if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio') {
							$custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($order_info['payment_custom_field'][$custom_field['custom_field_id']]);

							if ($custom_field_value_info) {
								$payment_custom_fields[] = array(
									'name'  => $custom_field['name'],
									'value' => $custom_field_value_info['name'],
									'sort_order' => $custom_field['sort_order']
								);
							}
						}

						if ($custom_field['type'] == 'checkbox' && is_array($order_info['payment_custom_field'][$custom_field['custom_field_id']])) {
							foreach ($order_info['payment_custom_field'][$custom_field['custom_field_id']] as $custom_field_value_id) {
								$custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($custom_field_value_id);

								if ($custom_field_value_info) {
									$payment_custom_fields[] = array(
										'name'  => $custom_field['name'],
										'value' => $custom_field_value_info['name'],
										'sort_order' => $custom_field['sort_order']
									);
								}
							}
						}

						if ($custom_field['type'] == 'text' || $custom_field['type'] == 'textarea' || $custom_field['type'] == 'file' || $custom_field['type'] == 'date' || $custom_field['type'] == 'datetime' || $custom_field['type'] == 'time') {
							$payment_custom_fields[] = array(
								'name'  => $custom_field['name'],
								'value' => $order_info['payment_custom_field'][$custom_field['custom_field_id']],
								'sort_order' => $custom_field['sort_order']
							);
						}

						if ($custom_field['type'] == 'file') {
							$upload_info = $this->model_tool_upload->getUploadByCode($order_info['payment_custom_field'][$custom_field['custom_field_id']]);

							if ($upload_info) {
								$payment_custom_fields[] = array(
									'name'  => $custom_field['name'],
									'value' => $upload_info['name'],
									'sort_order' => $custom_field['sort_order']
								);
							}
						}
					}
				}

				// Shipping
				$shipping_custom_fields = array();

				foreach ($custom_fields as $custom_field) {
					if ($custom_field['location'] == 'address' && isset($order_info['shipping_custom_field'][$custom_field['custom_field_id']])) {
						if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio') {
							$custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($order_info['shipping_custom_field'][$custom_field['custom_field_id']]);

							if ($custom_field_value_info) {
								$shipping_custom_fields[] = array(
									'name'  => $custom_field['name'],
									'value' => $custom_field_value_info['name'],
									'sort_order' => $custom_field['sort_order']
								);
							}
						}

						if ($custom_field['type'] == 'checkbox' && is_array($order_info['shipping_custom_field'][$custom_field['custom_field_id']])) {
							foreach ($order_info['shipping_custom_field'][$custom_field['custom_field_id']] as $custom_field_value_id) {
								$custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($custom_field_value_id);

								if ($custom_field_value_info) {
									$shipping_custom_fields[] = array(
										'name'  => $custom_field['name'],
										'value' => $custom_field_value_info['name'],
										'sort_order' => $custom_field['sort_order']
									);
								}
							}
						}

						if ($custom_field['type'] == 'text' || $custom_field['type'] == 'textarea' || $custom_field['type'] == 'file' || $custom_field['type'] == 'date' || $custom_field['type'] == 'datetime' || $custom_field['type'] == 'time') {
							$shipping_custom_fields[] = array(
								'name'  => $custom_field['name'],
								'value' => $order_info['shipping_custom_field'][$custom_field['custom_field_id']],
								'sort_order' => $custom_field['sort_order']
							);
						}

						if ($custom_field['type'] == 'file') {
							$upload_info = $this->model_tool_upload->getUploadByCode($order_info['shipping_custom_field'][$custom_field['custom_field_id']]);

							if ($upload_info) {
								$shipping_custom_fields[] = array(
									'name'  => $custom_field['name'],
									'value' => $upload_info['name'],
									'sort_order' => $custom_field['sort_order']
								);
							}
						}
					}
				}
Then, in admin/view/template/sale/order_invoice.twig file,

find:

Code: Select all

<b>{{ text_email }}</b> {{ order.store_email }}<br />
add below:

Code: Select all

{% if order.account_custom_fields %}
			  <table class="table table-bordered">
				<thead>
				  <tr>
					<td colspan="2">{{ text_account_custom_field }}</td>
				  </tr>
				</thead>
				<tbody>
				  {% for custom_field in order.account_custom_fields %}
					<tr>
					  <td>{{ custom_field.name }}</td>
					  <td>{{ custom_field.value }}</td>
					</tr>
				  {% endfor %}
				</tbody>
			  </table>
			  <br />
			{% endif %}
Then, find:

Code: Select all

<b>{{ text_payment_method }}</b> {{ order.payment_method }}<br />
add below:

Code: Select all

{% if order.payment_custom_fields %}
			  <table class="table table-bordered">
				<thead>
				  <tr>
					<td colspan="2">{{ text_payment_custom_field }}</td>
				  </tr>
				</thead>
				<tbody>
				  {% for custom_field in order.payment_custom_fields %}
					<tr>
					  <td>{{ custom_field.name }}</td>
					  <td>{{ custom_field.value }}</td>
					</tr>
				  {% endfor %}
				</tbody>
			  </table>
			  <br />
			{% endif %}
Then, find:

Code: Select all

<b>{{ text_shipping_method }}</b> {{ order.shipping_method }}
add below:

Code: Select all

{% if order.shipping_custom_fields %}
			  <table class="table table-bordered">
				<thead>
				  <tr>
					<td colspan="2">{{ text_shipping_custom_field }}</td>
				  </tr>
				</thead>
				<tbody>
				  {% for custom_field in order.shipping_custom_fields %}
					<tr>
					  <td>{{ custom_field.name }}</td>
					  <td>{{ custom_field.value }}</td>
					</tr>
				  {% endfor %}
				</tbody>
			  </table>
			{% endif %}
Then, follow this FAQ: viewtopic.php?f=134&t=215776#p718325

You can re-arrange the invoice presentation as you see fit.
Thank you.
Note: You forget to mention adding

Code: Select all

'shipping_custom_fields' => $shipping_custom_fields,
'payment_custom_fields' => $payment_custom_fields,

to

Code: Select all

$data['orders'][] = array(
Regards,

Newbie

Posts

Joined
Sun Jul 21, 2019 3:27 pm

Post by straightlight » Fri Apr 03, 2020 7:08 pm

moshair wrote:
Fri Apr 03, 2020 5:39 pm
Thank you.
Note: You forget to mention adding

'shipping_custom_fields' => $shipping_custom_fields,
'payment_custom_fields' => $payment_custom_fields,
I have now also added the account_custom_fields in the $data['orders'] array in the mean time.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member
Online

Posts

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

Post by moshair » Sat Apr 04, 2020 5:38 pm

straightlight wrote:
Fri Apr 03, 2020 7:08 pm
moshair wrote:
Fri Apr 03, 2020 5:39 pm
Thank you.
Note: You forget to mention adding

'shipping_custom_fields' => $shipping_custom_fields,
'payment_custom_fields' => $payment_custom_fields,
I have now also added the account_custom_fields in the $data['orders'] array in the mean time.
👍 Thank you.

Newbie

Posts

Joined
Sun Jul 21, 2019 3:27 pm

Post by ocusername » Wed May 06, 2020 9:54 am

UPDATE:
I turned "Google Shopping" module back ON and everything is still working perfectly when creating new products, or new copied products. Strange but, no more problems !

I hope this fix helps other people like myself who are not developers and don't know anything about programming.

PROBLEM:
I fixed an issue mentioned here regarding:

Code: Select all

 PHP Fatal error:  Uncaught exception 'Exception' with message 'Error: Duplicate entry '0' for key 'PRIMARY'<br />Error No: 1062<br />INSERT INTO `oc_product_advertise_google` (`product_id`, `store_id`, `google_product_category`) 
 
After installing a fresh copy of Opencart-3.0.31 and Journal-3 theme everything worked perfect except when I tried to create a new product when clicking the save button everything went blank and it seemed like the new product or the products I tried to copy did not get saved but actually after refreshing the broswer and going back to products page I found the new product or new copied products were actualy saved there and sometimes there were even multiple copies of the exact new product saved . In my CPanel I went to ADMIN folder and inside I found the "error_log" file. I viwed that file and thats how I found the error code above.

SOLUTION:
Thanks to other people posting here that this is an issue with the Opencart-3 Extension- Advertising-Google Shopping I deleted the Google Shopping Advertisement Extension and evrything works perfect.
1 ) I went to Opencart Admin
2 ) then to Extensions > then Extensions >> (submenu)
3 ) then I selected "Advertising" from the Extensions Drop Down Menu
When the "Google Shopping" module appeared I cliked on the Red "Delete" button to remove it from my Opencart.
Last edited by straightlight on Wed May 06, 2020 10:18 am, edited 1 time in total.
Reason: Added code tags.

Newbie

Posts

Joined
Fri Apr 14, 2017 8:50 am

Post by straightlight » Wed May 06, 2020 7:33 pm

ocusername wrote:
Wed May 06, 2020 9:54 am
UPDATE:
I turned "Google Shopping" module back ON and everything is still working perfectly when creating new products, or new copied products. Strange but, no more problems !

I hope this fix helps other people like myself who are not developers and don't know anything about programming.

PROBLEM:
I fixed an issue mentioned here regarding:

Code: Select all

 PHP Fatal error:  Uncaught exception 'Exception' with message 'Error: Duplicate entry '0' for key 'PRIMARY'<br />Error No: 1062<br />INSERT INTO `oc_product_advertise_google` (`product_id`, `store_id`, `google_product_category`) 
 
After installing a fresh copy of Opencart-3.0.31 and Journal-3 theme everything worked perfect except when I tried to create a new product when clicking the save button everything went blank and it seemed like the new product or the products I tried to copy did not get saved but actually after refreshing the broswer and going back to products page I found the new product or new copied products were actualy saved there and sometimes there were even multiple copies of the exact new product saved . In my CPanel I went to ADMIN folder and inside I found the "error_log" file. I viwed that file and thats how I found the error code above.

SOLUTION:
Thanks to other people posting here that this is an issue with the Opencart-3 Extension- Advertising-Google Shopping I deleted the Google Shopping Advertisement Extension and evrything works perfect.
1 ) I went to Opencart Admin
2 ) then to Extensions > then Extensions >> (submenu)
3 ) then I selected "Advertising" from the Extensions Drop Down Menu
When the "Google Shopping" module appeared I cliked on the Red "Delete" button to remove it from my Opencart.
Already fixed on the master branch.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member
Online

Posts

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

Post by xxvirusxx » Thu May 21, 2020 7:43 pm

Coupon pagination multi language fix: admin/controller/marketing/coupon.php

line 552 change this:

Code: Select all

'Showing %d to %d of %d (%d Pages)'
with this:

Code: Select all

$this->language->get('text_pagination')
Same issue in Master Branch but are too lazy to click on commit :laugh: reported in December 2019 :laugh:

OC 2.3.0.2 | OC 3.0.3.6 | Extensions converted by me | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by straightlight » Thu May 21, 2020 7:50 pm

xxvirusxx wrote:
Thu May 21, 2020 7:43 pm
Coupon pagination multi language fix: admin/controller/marketing/coupon.php

line 552 change this:

Code: Select all

'Showing %d to %d of %d (%d Pages)'
with this:

Code: Select all

$this->language->get('text_pagination')
Same issue in Master Branch but are too lazy to click on commit :laugh: reported in December 2019 :laugh:
Well, there's especially no need to wait all this time to publish such solutions where one would already know the answer about in order to create that commit and that is, if, the commit really hasn't been created in the first place on Github Opencart already.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member
Online

Posts

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

Post by xxvirusxx » Thu May 21, 2020 7:52 pm

Commit is here....

https://github.com/opencart/opencart/pull/7785/files

I work again on 3.0.3.3 to add fixes and I remember of this :)

OC 2.3.0.2 | OC 3.0.3.6 | Extensions converted by me | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by straightlight » Thu May 21, 2020 7:55 pm

xxvirusxx wrote:
Thu May 21, 2020 7:52 pm
Commit is here....

https://github.com/opencart/opencart/pull/7785/files

I work again on 3.0.3.3 to add fixes and I remember of this :)
Ah ! here it is. On your last post, this commit wasn't posted. Thanks for clarifying that.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member
Online

Posts

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

Post by turron16 » Sat Jun 06, 2020 8:33 pm

I have found a security bug in OpenCart. But I'm not able to PM the administrators. How do I do so?
PS. Do you guys award bug bounty?

Newbie

Posts

Joined
Sat Jun 06, 2020 7:42 pm

Post by straightlight » Sun Jun 07, 2020 5:30 am

turron16 wrote:
Sat Jun 06, 2020 8:33 pm
I have found a security bug in OpenCart. But I'm not able to PM the administrators. How do I do so?
PS. Do you guys award bug bounty?
Use the Contact us link at the bottom of the site to contact the Opencart team regarding your inquiry.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member
Online

Posts

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

Post by webmedialdh » Tue Jun 16, 2020 12:56 am

In 3.0.3.3 version, notice that on the time of edit orders from the backend. If we have custom fields for the address then it sends the data as

Code: Select all

 custom_field[$custom_field['custom_field_id']] 
but in the API controller it like that

Code: Select all

 $this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']] 
so location array not found thus it not allow users to edit the orders if have custom fields

Regards

Webx IT Solutions
Tel: +91 99154 09292, Skype: webmedialdh, Email: support@webxitsolutions.com
Image


User avatar
New member

Posts

Joined
Fri Apr 22, 2016 5:52 pm
Location - Ludhiana, Punjab

Post by straightlight » Tue Jun 16, 2020 6:28 am

webmedialdh wrote:
Tue Jun 16, 2020 12:56 am
In 3.0.3.3 version, notice that on the time of edit orders from the backend. If we have custom fields for the address then it sends the data as

Code: Select all

 custom_field[$custom_field['custom_field_id']] 
but in the API controller it like that

Code: Select all

 $this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']] 
so location array not found thus it not allow users to edit the orders if have custom fields

Regards
Where do you notice the custom_field[$custom_field['custom_field_id']] ? More information is needed.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member
Online

Posts

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

Post by webmedialdh » Tue Jun 16, 2020 4:01 pm

straightlight wrote:
Tue Jun 16, 2020 6:28 am
webmedialdh wrote:
Tue Jun 16, 2020 12:56 am
In 3.0.3.3 version, notice that on the time of edit orders from the backend. If we have custom fields for the address then it sends the data as

Code: Select all

 custom_field[$custom_field['custom_field_id']] 
but in the API controller it like that

Code: Select all

 $this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']] 
so location array not found thus it not allow users to edit the orders if have custom fields

Regards
Where do you notice the custom_field[$custom_field['custom_field_id']] ? More information is needed.

Hi Sir,

on the admin side:admin/view/template/sale/order_form.twig in the payment and shipping tabs
custom fields name are like custom_field[custom_field_id]
http://prntscr.com/t0kq5a

however, on the catalog side: api/payment/address and on api/shipping/address custom fields value are as follow
custom_field[location][custom_field_id]
http://prntscr.com/t0ktum

so when a user tries to edit the order it does not complete as custom field required error occurs

Regards

Webx IT Solutions
Tel: +91 99154 09292, Skype: webmedialdh, Email: support@webxitsolutions.com
Image


User avatar
New member

Posts

Joined
Fri Apr 22, 2016 5:52 pm
Location - Ludhiana, Punjab

Post by straightlight » Tue Jun 16, 2020 7:28 pm

Already fixed on the master branch and the pre-release version.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member
Online

Posts

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

Post by neptuneuk » Sat Aug 22, 2020 11:42 pm

Hi,

OC Version: 3.0.3.2

When you have run a 'Customer Searches Report' and move forward through the result set pages, when trying to return to the first page of the result set you are unable to do so (the url is malformed, as to reload the currently displayed result set page) e.g:
https://store.example.com/admin/index.p ... rch&page=3
as opposed to
https://store.example.com/admin/index.p ... mer_search

The same is true when using the 'previous page' icon '<' when you have arrived at page 2. You are unable to display page 1 as the url behind '<' is malformed, e.g when displaying page 2 the previous page '<' url is:
https://store.example.com/admin/index.p ... rch&page=2
presumably this should be:
https://store.example.com/admin/index.p ... mer_search

The correct behaviour seems to be present in all other reports I have tried, it seems to be isolated to 'Customer Searches Reports' only.

Newbie

Posts

Joined
Fri May 29, 2020 7:05 am

Active Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by lz1nud » Sun Oct 18, 2020 9:16 pm

OC 3.0.3.6 , currency rate is not changing, even if I press manual refresh, nothing happens. Is it only me, or it is a bug?

Sky-Mag Bulgaria


Active Member

Posts

Joined
Thu Feb 13, 2014 5:35 am
Location - Bulgaria

Post by straightlight » Sun Oct 18, 2020 9:53 pm

lz1nud wrote:
Sun Oct 18, 2020 9:16 pm
OC 3.0.3.6 , currency rate is not changing, even if I press manual refresh, nothing happens. Is it only me, or it is a bug?
I posted a solution recently about currency fix. This might be related from the master branch:

- https://github.com/opencart/opencart/pull/8723
- https://github.com/opencart/opencart/pull/8720
- https://github.com/opencart/opencart/pull/8717

One from condor2:

- https://github.com/opencart/opencart/pull/8250

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member
Online

Posts

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

Users browsing this forum: No registered users and 6 guests