Post by petpet » Tue Apr 03, 2018 2:37 am

Hello!!
in 2.3.0.2 in guest checkout
https://neobeauty.gr
All Guests has 6820 default rewardpoints.
Just put something in cart and go checkout
https://neobeauty.gr/index.php?route=checkout/checkout
where can i delete these points?

Newbie

Posts

Joined
Tue Dec 22, 2015 8:15 pm

Post by straightlight » Tue Apr 03, 2018 4:24 am

While there might be an extension for this, one quick way to restrict this feature would be by editing your catalog/model/checkout/order.php file.

Find all instances of:

Code: Select all

reward = '" . (int)$product['reward'] . "'"
replace with:

Code: Select all

reward = '" . (!isset($this->session->data['guest']) ? (int)$product['reward'] . "'" : '')
This should rectify the issue by preventing future rewards being added when a guest is using checkout.

For the points that were already added on the database, create a database backup. Then, create a new PHP file in your root admin folder of your fileserver named: reward_guest_remove.php . Then, paste in the following content:

Code: Select all

<?php

if (file_exists('./config.php')) {
	require_once('./config.php');
}

function library($class) {
	$file = DIR_SYSTEM . 'library/' . str_replace('\\', '/', strtolower($class)) . '.php';

	if (is_file($file)) {
		include_once($file);
		return true;
	} else {
		return false;
	}
}

spl_autoload_register('library');
spl_autoload_extensions('.php');

class import {
	public $db;

	public function __construct() {
		$this->db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
	}
}

$db = new import();

$query = $db->query("SELECT `op`.`order_product_id` FROM `" . DB_PREFIX . "order` `o` INNER JOIN `" . DB_PREFIX . "order_product` `op` ON (`op`.`order_id` = `o`.`order_id`) WHERE `o`.`customer_id` = '0' AND LENGTH(TRIM(`op`.`reward`)) > 0");

if ($query->num_rows) {
	foreach ($query->rows as $result) {
		$db->query("UPDATE `" . DB_PREFIX . "order_product` SET `reward` = '' WHERE `order_product_id` = '" . (int)$result['order_product_id'] . "'");
	}
}
Then, on your browser's admin folder, launch the reward_guest_remove.php file. This should resolved the issue. Once all updated, remove the PHP file from your fileserver.

Update: OC v1.5x API example can be found on this post: viewtopic.php?f=20&t=206911#p734188

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

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


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 5 guests