How to free shipping in Opencart based on total quantity? - opencart

My client requires Free shipping when Quantity Greater than or equal to 1000(qty>=1000).

Note : It's not recommended to make the direct changes in the core
files. You can make the vqmod for the same changes.
(1) Need to enable Free shipping from admin panel
Go to Admin -> Extensions-> shipping-> Free shipping -> Enable it
(2) Open file catalog/model/shipping/free.php and search for
if (!$this->config->get('free_geo_zone_id')) {
$status = true;
} elseif ($query->num_rows) {
$status = true;
}
and replace below code
if (!$this->config->get('free_geo_zone_id') && ($this->cart->countProducts())>=1000) {
$status = true;
} elseif ($query->num_rows && ($this->cart->countProducts())>=1000) {
$status = true;
}

We are using Free Shipping Plus that allow a lot of customizations on offering free shipping to our customers.

Related

How to remove +91 from Indian phone numbers in Ameyo

In an inbound contact center for customer service, the phone numbers in the callerid are prefixed with 0 or sometimes with 91. A few inhouse CRMs require very precise phone number without these prefixes. For the CRM popup to work well, it is required that Ameyo removes such prefix, if present. How can it be done
Enable Call Context Inbound Srcphone Script from configuration and paste the following script.
​
if(null !=srcphone && srcphone.length>10 && srcphone.charAt(0) =='9' && srcphone.charAt(1) =='1'){
var srcphoneWithout91 = srcphone.substring(2,srcphone.length);
srcphone=srcphoneWithout91;
}
else if(null !=srcphone && srcphone.length>10 && srcphone.charAt(0) =='0'){
var srcphoneWithout91 = srcphone.substring(1,srcphone.length);
srcphone=srcphoneWithout91;
}
else {
srcphone;
}

opencart custom payment extension is not showing in the payment method

I am writing a custom payment extension in opencart 3. I have setup necessary method and the plugin is not enabling. I am trying to enable the plugin automatically after installation it does work yet.
These are my code.
directory> upload/admin/controller/extension/mycustom.php
private $info_status = true;
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->model_setting_setting->editSetting('gtpayment', $this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true));
}
if (isset($this->request->post['gtpayment_status'])) {
$data['gtpayment_status'] = $this->request->post['gtpayment_status'];
}else{
$data['gtpayment_status'] = $this->config->get('gtpayment_status');
}
If these code is not correct is there a possible way to make a plugin automatically enable after installation.
1 - You missed payment folder under extension folder.
2 - If your actual module is gtpayment, your module filename and your classname must be gtpayment:
admin/controller/extension/payment/gtpayment.php
And
class ControllerExtensionPaymentGtpayment extends Controller {
3 - You must use $data['payment_gtpayment_status'] instead $data['gtpayment_status']
Extensions are now prefixed by their category. so paypal_status would
become payment_papal_status
Source of quote

Query Facebook Opengraph next page parameters

I am unable to implement pagination with Facebook OpenGraph. I have exhausted every option I have found.
My hope is to query for 500 listens repeatedly until there are none left. However, I am only able to receive a response from my first query. Below is my current code, but I have tried setting the parameters to different amounts rather than having the fields from the [page][next] dictate them
$q_param['limit'] = 500;
$next_exists = true;
while($next_exists){
$music = $facebook->api('/me/music.listens','GET', $q_param);
$music_data = array_merge($music_data, $music['data']);
if($music["paging"]["next"]==null || $music["paging"]["next"]=="")
$next_exists = false;
else{
$url = $music["paging"]["next"];
parse_str(parse_url($url, PHP_URL_QUERY), $array);
foreach ($array as $key => $value) {
$q_param[$key]=$value;
}
}
}
}
a - Can you please share what do you get after first call?
b - Also, possible if you can share the whole file?
I think your script is timing out. Try adding following on top of your file:
set_time_limit(0);
Can you check apache log files?
sudo tail -f /var/log/apache2/error.log

Login only prestashop catalog

Im building a prestashop catalog, but it needs to be visible to logged in customers only. Is this possible. It would be nice if the built in prestashop login is used for this.. any help is appreciated.
I have a suggestion. You can use the Customer Groups feature in PrestaShop 1.5 and only allow logged in customers to see the prices. For every Customer that is grouped in Visitor, they would see your website in Catalog Mode.
Prestashop 1.5 solution:
Simply upload the original file:
classes\controller\FrontController.php
into:
override/classes/controller/FrontController.php
Next, rename the class. Final code should look like this:
class FrontController extends FrontControllerCore
{
public function init()
{
parent::init();
if (!$this->context->customer->isLogged() && $this->php_self != 'authentication' && $this->php_self != 'password')
{
Tools::redirect('index.php?controller=authentication?back=my-account');
}
}
}
The last step is to manually delete the following file so prestashop is aware of the overriden class (It will be re-generated automatically):
cache/class_index.php
And voilà, functionality achieved without overwriting core files.
It'll be easy.
Use this code:
if(!self::$cookie->isLogged(true) AND in_array($this->step, array(1, 2, 3)))
Tools::redirect('authentication.php');
In the preprocess of your indexController
Here’s my solution, it works like a charm and is a very easy fix!
In classes\Configuration.php (around line 114) it looks like this
static public function get($key, $id_lang = NULL)
{
if ($id_lang AND isset(self::$_CONF_LANG[(int)$id_lang][$key]))
return self::$_CONF_LANG[(int)$id_lang][$key];
elseif (is_array(self::$_CONF) AND key_exists($key, self::$_CONF))
return self::$_CONF[$key];
return false;
}
change it to this:
static public function get($key, $id_lang = NULL)
{
//Grab access to the $cookie which is already loaded in the FrontController as global $cookie;
global $cookie;
if ($id_lang AND isset(self::$_CONF_LANG[(int)$id_lang][$key]))
return self::$_CONF_LANG[(int)$id_lang][$key];
elseif (is_array(self::$_CONF) AND key_exists($key, self::$_CONF))
//If the system is trying to find out if Catalog Mode is ON, then return the configuration setting,
//but override it with the user logon status
if($key == 'PS_CATALOG_MODE')
{
return !$cookie->logged || self::$_CONF[$key];
}
else
{
return self::$_CONF[$key];
}
return false;
}
Essentially, I wanted to force the system to display the “Catalog Mode” when the user is not logged in, and to turn this off when he is logged in.
I can guarantee this works for v1.4.3.0 and the code for the current version 1.4.8.2 (at the time of this post) has not changed, so it should work there.

Defining lists in VCL (Varnish Configuration Language)

Is there a way to define lists of domains in Varnish VCL language? I suppose something similar for ACLs. I would like to do something like this (using ACLs as an example).
acl website_list {
'(www\.)?domain.tld';
'(www\.)?domain2.tld';
}
...
if(req.http.Host ~ website_list) return(lookup);
I could just use separate RegEx tests but it isn't very re-usable if I want to use those domains somewhere else in the VCL.
Thanks!
You could have a test condition which sets a marker header, then test for that later on:
sub vcl_recv {
if (req.http.Host ~ "^(www\.)?domain.tld" ||
req.http.Host ~ "^(www\.)?domain2.tld") {
/* Set the magic marker */
set beresp.http.magicmarker = "1";
}
if (resp.http.magicmarker) {
return(lookup);
}
}