mirror of
https://github.com/retailcrm/opencart-module.git
synced 2025-04-07 19:22:02 +00:00
Compare commits
65 commits
Author | SHA1 | Date | |
---|---|---|---|
|
b1d013dd30 | ||
|
c5916fc8f2 | ||
|
2c6cccc3b1 | ||
|
c893cf24fb | ||
|
d5f29dc5fe | ||
|
3a30986e4b | ||
|
571263ca2c | ||
|
a375804086 | ||
|
a56ce789ed | ||
|
f5f55dd449 | ||
|
62605b11ed | ||
|
22a9c2d819 | ||
|
a2a4eca8c7 | ||
|
63f625b329 | ||
|
6a7f395116 | ||
|
792546d007 | ||
|
7d3390bc02 | ||
|
ef6d09c03a | ||
|
e4cfdd8c9f | ||
|
8b7522ca6c | ||
|
b6181ab426 | ||
|
3e1c19fd8d | ||
|
090a5783c5 | ||
|
feaeca458f | ||
|
b22941cc3e | ||
|
6790cf7b0e | ||
463485509e | |||
|
78806e4aef | ||
|
4f15310fbb | ||
a1f97bc996 | |||
|
d058173aa4 | ||
|
4e09c021c8 | ||
f4e892d71a | |||
|
92d94c919e | ||
|
8445980d5a | ||
|
072b3a95b0 | ||
|
a0337479ae | ||
|
9e85d3bffb | ||
|
60998ad74f | ||
|
08df9043fa | ||
|
7cdab05aa2 | ||
|
4359f084bd | ||
|
6391f49d2b | ||
|
828cc72930 | ||
|
7ed233450c | ||
|
24222d66ca | ||
|
ff87f7939e | ||
|
bb23c4cc40 | ||
|
cd7f63562d | ||
|
29bdecfc96 | ||
|
75fc11c6f9 | ||
|
fb7290f865 | ||
|
c2abd5acd8 | ||
|
579150ea08 | ||
|
769f35f379 | ||
|
1d9110c364 | ||
|
28391f4134 | ||
|
2dbb56897e | ||
|
85f47c1984 | ||
2dbccd8a02 | |||
|
739c2775b5 | ||
|
6b2d6aeb80 | ||
|
6a221ab5f8 | ||
|
bc16a2a6f3 | ||
|
85de4835d5 |
62 changed files with 1757 additions and 1074 deletions
|
@ -2,7 +2,7 @@ FROM php:7.1-apache
|
||||||
|
|
||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
|
|
||||||
RUN apt-get install -y netcat zlib1g-dev libpq-dev git libicu-dev libxml2-dev libpng-dev libjpeg-dev libmcrypt-dev libxslt-dev libfreetype6-dev \
|
RUN apt-get install -y netcat zlib1g-dev libpq-dev git libicu-dev libxml2-dev libpng-dev libjpeg-dev libmcrypt-dev libxslt-dev libfreetype6-dev unzip \
|
||||||
&& docker-php-ext-configure intl \
|
&& docker-php-ext-configure intl \
|
||||||
&& docker-php-ext-install intl \
|
&& docker-php-ext-install intl \
|
||||||
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
|
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
|
||||||
|
@ -23,9 +23,9 @@ RUN wget -O /usr/bin/phpunit https://phar.phpunit.de/phpunit-7.phar && chmod +x
|
||||||
RUN curl --insecure https://getcomposer.org/download/1.9.3/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer
|
RUN curl --insecure https://getcomposer.org/download/1.9.3/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer
|
||||||
|
|
||||||
# Set timezone
|
# Set timezone
|
||||||
RUN rm /etc/localtime
|
RUN rm /etc/localtime && \
|
||||||
RUN ln -s /usr/share/zoneinfo/Europe/Moscow /etc/localtime
|
ln -s /usr/share/zoneinfo/Europe/Moscow /etc/localtime && \
|
||||||
RUN "date"
|
"date"
|
||||||
|
|
||||||
ARG TEST_SUITE
|
ARG TEST_SUITE
|
||||||
ARG OPENCART
|
ARG OPENCART
|
||||||
|
@ -51,6 +51,8 @@ ENV OC_EMAIL=${OC_EMAIL}
|
||||||
|
|
||||||
ADD .docker/entrypoint.sh /usr/local/bin/docker-php-entrypoint
|
ADD .docker/entrypoint.sh /usr/local/bin/docker-php-entrypoint
|
||||||
|
|
||||||
RUN sed -i "s/80/$PORT/g" /etc/apache2/sites-enabled/000-default.conf /etc/apache2/ports.conf
|
RUN chmod +x /usr/local/bin/docker-php-entrypoint
|
||||||
RUN sed -i 's/var\/www\/html/opencart-module\/www/g' /etc/apache2/sites-enabled/000-default.conf
|
|
||||||
RUN sed -i 's/var\/www/opencart-module/g' /etc/apache2/apache2.conf
|
RUN sed -i "s/80/$PORT/g" /etc/apache2/sites-enabled/000-default.conf /etc/apache2/ports.conf && \
|
||||||
|
sed -i 's/var\/www\/html/opencart-module\/www/g' /etc/apache2/sites-enabled/000-default.conf && \
|
||||||
|
sed -i 's/var\/www/opencart-module/g' /etc/apache2/apache2.conf
|
||||||
|
|
|
@ -8,8 +8,10 @@ done
|
||||||
|
|
||||||
make -C /opencart-module run
|
make -C /opencart-module run
|
||||||
|
|
||||||
mkdir /opencart-module/www/system/storage/session
|
mkdir -p /opencart-module/www/system/storage/session
|
||||||
|
|
||||||
|
sed -i 's/\?>//g' /opencart-module/www/config.php
|
||||||
|
sed -i 's/\?>//g' /opencart-module/www/admin/config.php
|
||||||
echo '\nini_set("session.save_path", DIR_SYSTEM . "storage/session");' >> /opencart-module/www/config.php
|
echo '\nini_set("session.save_path", DIR_SYSTEM . "storage/session");' >> /opencart-module/www/config.php
|
||||||
echo '\nini_set("session.save_path", DIR_SYSTEM . "storage/session");' >> /opencart-module/www/admin/config.php
|
echo '\nini_set("session.save_path", DIR_SYSTEM . "storage/session");' >> /opencart-module/www/admin/config.php
|
||||||
|
|
||||||
|
|
12
.env-dist
12
.env-dist
|
@ -1,8 +1,8 @@
|
||||||
# OpenCart Database connection values
|
# OpenCart Database connection values
|
||||||
OC_DB_HOSTNAME=host
|
OC_DB_HOSTNAME=mysql
|
||||||
OC_DB_USERNAME=user
|
OC_DB_USERNAME=opencart
|
||||||
OC_DB_PASSWORD=pass
|
OC_DB_PASSWORD=opencart
|
||||||
OC_DB_DATABASE=database
|
OC_DB_DATABASE=opencart
|
||||||
OC_DB_DRIVER=mysqli
|
OC_DB_DRIVER=mysqli
|
||||||
|
|
||||||
# OpenCart Administration user
|
# OpenCart Administration user
|
||||||
|
@ -14,5 +14,5 @@ OC_EMAIL=you@example.com
|
||||||
SERVER_PORT=8080
|
SERVER_PORT=8080
|
||||||
SERVER_URL=http://localhost
|
SERVER_URL=http://localhost
|
||||||
|
|
||||||
TEST_SUITE=
|
TEST_SUITE=3
|
||||||
OPENCART=
|
OPENCART=3.0.2.0
|
||||||
|
|
202
.github/workflows/ci.yml
vendored
Normal file
202
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,202 @@
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '**'
|
||||||
|
tags-ignore:
|
||||||
|
- '*.*'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
env:
|
||||||
|
OC_DB_HOSTNAME: 127.0.0.1
|
||||||
|
OC_DB_USERNAME: root
|
||||||
|
OC_DB_PASSWORD: root
|
||||||
|
OC_DB_DATABASE: tests_opencart
|
||||||
|
OC_DB_DRIVER: mysqli
|
||||||
|
OC_USERNAME: admin
|
||||||
|
OC_PASSWORD: admin
|
||||||
|
OC_EMAIL: test@test.com
|
||||||
|
SERVER_PORT: 80
|
||||||
|
SERVER_URL: http://localhost
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- php-version: '7.3'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.1.1'
|
||||||
|
- php-version: '7.3'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.1.2'
|
||||||
|
- php-version: '7.3'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.2.0'
|
||||||
|
- php-version: '7.3'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.0'
|
||||||
|
- php-version: '7.3'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.1'
|
||||||
|
- php-version: '7.3'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.2'
|
||||||
|
- php-version: '7.3'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.3'
|
||||||
|
- php-version: '7.3'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.4'
|
||||||
|
- php-version: '7.3'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.5'
|
||||||
|
- php-version: '7.3'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.6'
|
||||||
|
- php-version: '7.3'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.7'
|
||||||
|
- php-version: '7.3'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.8'
|
||||||
|
- php-version: '7.4'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.1.1'
|
||||||
|
- php-version: '7.4'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.1.2'
|
||||||
|
- php-version: '7.4'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.2.0'
|
||||||
|
- php-version: '7.4'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.0'
|
||||||
|
- php-version: '7.4'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.1'
|
||||||
|
- php-version: '7.4'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.2'
|
||||||
|
- php-version: '7.4'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.3'
|
||||||
|
- php-version: '7.4'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.4'
|
||||||
|
- php-version: '7.4'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.5'
|
||||||
|
- php-version: '7.4'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.6'
|
||||||
|
- php-version: '7.4'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.7'
|
||||||
|
- php-version: '7.4'
|
||||||
|
test-suite: '3'
|
||||||
|
oc: '3.0.3.8'
|
||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mysql:5.7
|
||||||
|
env:
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: false
|
||||||
|
MYSQL_ROOT_PASSWORD: ${{ env.OC_DB_PASSWORD }}
|
||||||
|
MYSQL_DATABASE: ${{ env.OC_DB_DATABASE }}
|
||||||
|
ports:
|
||||||
|
- 3306:3306
|
||||||
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup PHP ${{ matrix.php-version }}
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-version }}
|
||||||
|
coverage: xdebug
|
||||||
|
tools: composer:v1
|
||||||
|
extensions: gd, mbstring, mysqli, zip, mcrypt, mysql, pdo_mysql, dom
|
||||||
|
- name: Install Opencart
|
||||||
|
env:
|
||||||
|
TEST_SUITE: ${{ matrix.test-suite }}
|
||||||
|
OPENCART: ${{ matrix.oc }}
|
||||||
|
run: make before_script
|
||||||
|
- name: Run tests
|
||||||
|
env:
|
||||||
|
TEST_SUITE: ${{ matrix.test-suite }}
|
||||||
|
OPENCART: ${{ matrix.oc }}
|
||||||
|
run: composer test
|
||||||
|
- name: Coverage
|
||||||
|
env:
|
||||||
|
COVERAGE: ${{ matrix.coverage }}
|
||||||
|
if: env.COVERAGE == 1
|
||||||
|
run: |
|
||||||
|
make coverage
|
||||||
|
bash <(curl -s https://codecov.io/bash)
|
||||||
|
phpcs:
|
||||||
|
needs: ['test']
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup PHP 7.2
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '7.2'
|
||||||
|
tools: composer:v1
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install
|
||||||
|
- name: Check compatibility
|
||||||
|
run: make phpcomp
|
||||||
|
deploy:
|
||||||
|
needs: ['phpcs']
|
||||||
|
if: success() && github.event_name == 'push' && github.repository_owner == 'retailcrm' && github.ref == 'refs/heads/master'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup PHP 7.2
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '7.2'
|
||||||
|
tools: composer:v1
|
||||||
|
- name: Build release
|
||||||
|
run: |
|
||||||
|
git fetch origin --unshallow --tags
|
||||||
|
export LAST_TAG=`git describe --abbrev=0 --tags`
|
||||||
|
export VERSION=`cat VERSION`
|
||||||
|
export ARCHIVE_NAME=retailcrm-$VERSION.ocmod.zip
|
||||||
|
export ARCHIVE_PATH="/tmp/$ARCHIVE_NAME"
|
||||||
|
export RELEASE_TAG=v$VERSION
|
||||||
|
export LAST_COMMIT=`git log --oneline --format=%B -n 1 HEAD | head -n 1`
|
||||||
|
echo RELEASE_TAG=$RELEASE_TAG >> $GITHUB_ENV
|
||||||
|
echo LAST_TAG=$LAST_TAG >> $GITHUB_ENV
|
||||||
|
echo LAST_COMMIT=$LAST_COMMIT >> $GITHUB_ENV
|
||||||
|
echo ARCHIVE_PATH=$ARCHIVE_PATH >> $GITHUB_ENV
|
||||||
|
echo ARCHIVE_NAME=$ARCHIVE_NAME >> $GITHUB_ENV
|
||||||
|
make build_archive
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
if: env.LAST_TAG != env.RELEASE_TAG
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ env.RELEASE_TAG }}
|
||||||
|
release_name: ${{ env.RELEASE_TAG }}
|
||||||
|
body: ${{ env.LAST_COMMIT }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
- name: Upload Release Asset
|
||||||
|
id: upload-release-asset
|
||||||
|
if: env.LAST_TAG != env.RELEASE_TAG
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ${{ env.ARCHIVE_PATH }}
|
||||||
|
asset_name: ${{ env.ARCHIVE_NAME }}
|
||||||
|
asset_content_type: application/zip
|
||||||
|
- name: Cleanup
|
||||||
|
if: env.LAST_TAG != env.RELEASE_TAG
|
||||||
|
run: make delete_archive
|
140
.travis.yml
140
.travis.yml
|
@ -1,140 +0,0 @@
|
||||||
os: linux
|
|
||||||
language: php
|
|
||||||
dist: trusty
|
|
||||||
|
|
||||||
if: tag IS blank
|
|
||||||
|
|
||||||
env:
|
|
||||||
global:
|
|
||||||
- OC_DB_HOSTNAME=localhost
|
|
||||||
- OC_DB_USERNAME=root
|
|
||||||
- OC_DB_PASSWORD=root
|
|
||||||
- OC_DB_DATABASE=tests_opencart
|
|
||||||
- OC_DB_DRIVER=mysqli
|
|
||||||
- OC_USERNAME=admin
|
|
||||||
- OC_PASSWORD=admin
|
|
||||||
- OC_EMAIL=test@test.com
|
|
||||||
- SERVER_PORT=80
|
|
||||||
- SERVER_URL=http://localhost
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- test
|
|
||||||
- deploy
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- export LAST_TAG=`git describe --abbrev=0 --tags`
|
|
||||||
- export CURRENT_VERSION=v`cat VERSION`
|
|
||||||
|
|
||||||
before_script: make before_script
|
|
||||||
|
|
||||||
script: composer test
|
|
||||||
|
|
||||||
after_success:
|
|
||||||
- make coverage
|
|
||||||
- bash <(curl -s https://codecov.io/bash)
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
include:
|
|
||||||
- php: 7.0
|
|
||||||
env: TEST_SUITE=2.3 OPENCART=2.3.0.0
|
|
||||||
- php: 7.0
|
|
||||||
env: TEST_SUITE=2.3 OPENCART=2.3.0.1
|
|
||||||
- php: 7.0
|
|
||||||
env: TEST_SUITE=2.3 OPENCART=2.3.0.2
|
|
||||||
- php: 7.1
|
|
||||||
env: TEST_SUITE=2.3 OPENCART=2.3.0.0
|
|
||||||
- php: 7.1
|
|
||||||
env: TEST_SUITE=2.3 OPENCART=2.3.0.1
|
|
||||||
- php: 7.1
|
|
||||||
env: TEST_SUITE=2.3 OPENCART=2.3.0.2
|
|
||||||
- php: 7.0
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.0.0
|
|
||||||
- php: 7.0
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.0.2
|
|
||||||
- php: 7.0
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.1.0
|
|
||||||
- php: 7.0
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.1.1
|
|
||||||
- php: 7.0
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.1.2
|
|
||||||
- php: 7.0
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.2.0
|
|
||||||
- php: 7.0
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.3.0
|
|
||||||
- php: 7.0
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.3.1
|
|
||||||
- php: 7.0
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.3.2
|
|
||||||
- php: 7.1
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.0.0
|
|
||||||
- php: 7.1
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.0.2
|
|
||||||
- php: 7.1
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.1.0
|
|
||||||
- php: 7.1
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.1.1
|
|
||||||
- php: 7.1
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.1.2
|
|
||||||
- php: 7.1
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.2.0
|
|
||||||
- php: 7.1
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.3.0
|
|
||||||
- php: 7.1
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.3.1
|
|
||||||
- php: 7.1
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.3.2
|
|
||||||
- php: 7.2
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.0.0
|
|
||||||
- php: 7.2
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.0.2
|
|
||||||
- php: 7.2
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.1.0
|
|
||||||
- php: 7.2
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.1.1
|
|
||||||
- php: 7.2
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.1.2
|
|
||||||
- php: 7.2
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.2.0
|
|
||||||
- php: 7.2
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.3.0
|
|
||||||
- php: 7.2
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.3.1
|
|
||||||
- php: 7.2
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.3.2
|
|
||||||
- php: 7.3
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.0.0
|
|
||||||
- php: 7.3
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.0.2
|
|
||||||
- php: 7.3
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.1.0
|
|
||||||
- php: 7.3
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.1.1
|
|
||||||
- php: 7.3
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.1.2
|
|
||||||
- php: 7.3
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.2.0
|
|
||||||
- php: 7.3
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.3.0
|
|
||||||
- php: 7.3
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.3.1
|
|
||||||
- php: 7.3
|
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.3.2
|
|
||||||
- stage: deploy
|
|
||||||
before_script: skip
|
|
||||||
script: make build_archive
|
|
||||||
before_deploy:
|
|
||||||
- export VERSION=`cat VERSION`
|
|
||||||
- export ARCHIVE_NAME=/tmp/retailcrm-$VERSION.ocmod.zip
|
|
||||||
- git config --local user.name "retailCRM"
|
|
||||||
- git config --local user.email "support@retailcrm.ru"
|
|
||||||
- export TRAVIS_TAG=v$VERSION
|
|
||||||
- git tag $TRAVIS_TAG
|
|
||||||
deploy:
|
|
||||||
provider: releases
|
|
||||||
token: $GITHUB_OAUTH_TOKEN
|
|
||||||
cleanup: false
|
|
||||||
file: $ARCHIVE_NAME
|
|
||||||
on:
|
|
||||||
condition: "$LAST_TAG != $CURRENT_VERSION"
|
|
||||||
if: branch = master AND type = push AND fork = false
|
|
||||||
after_deploy: make delete_archive
|
|
176
CHANGELOG.md
176
CHANGELOG.md
|
@ -1,112 +1,182 @@
|
||||||
|
## v4.1.19
|
||||||
|
* Added option to round order amount
|
||||||
|
|
||||||
|
## v4.1.18
|
||||||
|
* Fixed constant with version of module.
|
||||||
|
|
||||||
|
## v4.1.17
|
||||||
|
* Added additional parameters to GET requests.
|
||||||
|
|
||||||
|
## v4.1.16
|
||||||
|
* Support for services in ICML
|
||||||
|
|
||||||
|
## v4.1.15
|
||||||
|
* Display module version
|
||||||
|
|
||||||
|
## v4.1.14
|
||||||
|
* Added currency validation when configuring the module
|
||||||
|
|
||||||
|
## v4.1.13
|
||||||
|
* Changed the logic of customer subscriptions to promotional newsletters
|
||||||
|
|
||||||
|
## v4.1.12
|
||||||
|
* Added escaping for db query in method for getting zone
|
||||||
|
|
||||||
|
## v4.1.11
|
||||||
|
* Fixed the transfer of the weight offers
|
||||||
|
|
||||||
|
## v4.1.10
|
||||||
|
* Types of deliveries and payments are displayed only active status and available stores
|
||||||
|
|
||||||
|
## v4.1.9
|
||||||
|
* Optimization of the history processing algorithm
|
||||||
|
|
||||||
|
## v4.1.8
|
||||||
|
* Fixed customer externalId when creating a customer and sending it to RetailCRM
|
||||||
|
|
||||||
|
## v4.1.7
|
||||||
|
* Fixed notices in ICML generation and while setting delivery type
|
||||||
|
* Fixed incorrect data check before setting payment data
|
||||||
|
* Some other minor improvements
|
||||||
|
|
||||||
|
## v4.1.6
|
||||||
|
* Fix for typo in the history routine
|
||||||
|
* Fix for incorrect protocol in the ICML product image links
|
||||||
|
|
||||||
|
## v4.1.5
|
||||||
|
* Send discount details into the system
|
||||||
|
* Prefix for payment external ID (to ensure that it's unique)
|
||||||
|
* Make payment sum optional
|
||||||
|
* Weight calculation based on product options
|
||||||
|
|
||||||
|
## v.4.1.4
|
||||||
|
* Create payment only when the payment type is specified
|
||||||
|
* Checking the availability of promotional price for the product when uploading the order
|
||||||
|
|
||||||
|
## v.4.1.3
|
||||||
|
* Removed the ability to specify the API version
|
||||||
|
|
||||||
|
## v.4.1.2
|
||||||
|
* Added accounting for a gift certificate price when creating an order and sending it to RetailCRM
|
||||||
|
|
||||||
|
## v.4.1.1
|
||||||
|
* Updated the mechanics of processing customer addresses
|
||||||
|
|
||||||
|
## v.4.1.0
|
||||||
|
* Added the ability to connect Online Consultant
|
||||||
|
|
||||||
|
## v.4.0.1
|
||||||
|
* Fixed the transfer of coupon discounts
|
||||||
|
* Fixed console commands
|
||||||
|
|
||||||
## v.4.0.0
|
## v.4.0.0
|
||||||
* Поддержка корпоративных клиентов
|
* Added support for corporate customers
|
||||||
* Поддержка изменения покупателя в заказе
|
* Added support for changing the customer in the order
|
||||||
|
|
||||||
## v.3.3.9
|
## v.3.3.9
|
||||||
* Исправлены цены в ICML
|
* Fixed prices in ICML
|
||||||
|
|
||||||
## v.3.3.8
|
## v.3.3.8
|
||||||
* Исправлен вывод предупреждений при генерации ICML
|
* Fixed warnings output when generating ICML
|
||||||
|
|
||||||
## v.3.3.7
|
## v.3.3.7
|
||||||
* Изменена конфигурация travis-ci для сборки
|
* Changed the configuration of travis-ci for build
|
||||||
|
|
||||||
## v.3.3.6
|
## v.3.3.6
|
||||||
* Небольшие фиксы
|
* Minor bug fixes
|
||||||
|
|
||||||
## v.3.3.5
|
## v.3.3.5
|
||||||
* Добавлена генерация габаритов в каталоге
|
* Added generation of dimensions in the catalog
|
||||||
|
|
||||||
## v.3.3.4
|
## v.3.3.4
|
||||||
* Исправлен баг с некорректной выгрузкой акционных цен для товаров с характеристиками
|
* Fixed a bug with incorrect uploading of promotional prices for products with characteristics
|
||||||
|
|
||||||
## v.3.3.3
|
## v.3.3.3
|
||||||
* Добавлено удаление типа цены товара для неустановленных акционных цен
|
* Added removal of product's price type for unidentified promotional prices
|
||||||
|
|
||||||
## v.3.3.2
|
## v.3.3.2
|
||||||
* Добавлен возврат остатка товара при отмене заказа
|
* Added the return of leftover product stocks when the order is canceled
|
||||||
|
|
||||||
## v.3.3.1
|
## v.3.3.1
|
||||||
* Исправлен баг с передачей данных заказа в retailCRM при получении истории изменений от retailCRM
|
* Fixed a bug with sending order data to RetailCRM when receiving the history of changes from RetailCRM
|
||||||
|
|
||||||
## v.3.3.0
|
## v.3.3.0
|
||||||
* Добавена настройка записи истории изменения заказов в Opencart
|
* Added setting for recording the history of order changes in Opencart
|
||||||
* Устранен баг с вызовом события редактирования заказа при выгрузке истории изменений из retailCRM
|
* Fixed a bug with calling the order editing event when uploading the history of changes from RetailCRM
|
||||||
* Добавлена передача типа цены при создании и редактировании заказа
|
* Added transfer of the price type when creating or editing an order
|
||||||
|
|
||||||
## v.3.2.4
|
## v.3.2.4
|
||||||
* Добавлена возможность передачи акционных цен для нескольких групп пользователей
|
* Added the ability to transfer promotional prices for multiple user groups
|
||||||
* Добавлена передача нулевой цены для неустановленных акционных цен
|
* Added the ability to transfer zero price for unspecified promotional prices
|
||||||
* Убрана базовая цена retailcrm из настроек соответствия типов цен
|
* Removed the retailcrm base price from the price types conformity settings
|
||||||
|
|
||||||
## v.3.2.2
|
## v.3.2.2
|
||||||
* Убрана генерация externalId покупателя при заказе без регистрации на сайте.
|
* Removed generation of the customer's externalId when order was created without registeration on the website.
|
||||||
|
|
||||||
## v.3.2.1
|
## v.3.2.1
|
||||||
* Изменена логика передачи данных по заказам и клиентам. Контактные данные по доставке передаются в карточку заказа, контактные данные плательщика в карточку клиента.
|
* Changed the logic for transferring data for orders and customers. Contact information for delivery is transferred to the order's card, and the payer's contact information is transferred to the customer's card.
|
||||||
|
|
||||||
## v.3.2.0
|
## v.3.2.0
|
||||||
* Добавлена выгрузка картинок для категорий в ICML
|
* Added uploading images for categories in ICML
|
||||||
* Добавлена настройка для выбора валюты, в которой будет выгружаться цена в ICML
|
* Added setting for selecting the currency in which the price will be uploaded in ICML
|
||||||
|
|
||||||
## v.3.1.6
|
## v.3.1.6
|
||||||
* Исправлено получение событий из БД для OC 3.0
|
* Fixed getting events from the database for OC 3.0
|
||||||
|
|
||||||
## v.3.1.5
|
## v.3.1.5
|
||||||
* Исправление ошибок
|
* Bug fixes
|
||||||
|
|
||||||
## v.3.1.4
|
## v.3.1.4
|
||||||
* Исправлена некорректная склейка типов доставки
|
* Fixed incorrect combining of delivery types
|
||||||
|
|
||||||
## v.3.1.3
|
## v.3.1.3
|
||||||
* Добавлена активация модуля в маркетплейсе retailCRM
|
* Added module activation in the RetailCRM marketplace
|
||||||
|
|
||||||
## v.3.1.2
|
## v.3.1.2
|
||||||
* Добавлен перевод на испанский язык
|
* Added Spanish translation
|
||||||
* Переделан перевод на английский язык
|
* Reworked English translation
|
||||||
|
|
||||||
## v.3.1.1
|
## v.3.1.1
|
||||||
* Добавлено создание клиента при ручной выгрузке заказа из админки
|
* Added customer creation when manually uploading an order from admin panel
|
||||||
|
|
||||||
## v.3.1.0
|
## v.3.1.0
|
||||||
* Переработан дизайн шаблона twig
|
* Redesigned the twig template
|
||||||
* Добавлена настройка передачи номера заказа в retailCRM
|
* Added a setting for transmitting the order number to RetailCRM
|
||||||
* Улучшена механика передачи типа доставки в retailCRM
|
* Improved mechanics of delivery type transfer to RetailCRM
|
||||||
* Исправлена ошибка при выгрузке единичного заказа в админ панели
|
* Fixed an error when uploading a single order in admin panel
|
||||||
|
|
||||||
## v.3.0.5
|
## v.3.0.5
|
||||||
* Исправлены ошибки в шаблоне twig
|
* Fixed errors in the twig template
|
||||||
* Добавлена обработка истории изменений при сохранении настроек для установки текущего sinceId, если история в retailCRM пустая
|
* Added processing of the history of changes when saving settings for setting the current sinceId, if the history in RetailCRM is empty
|
||||||
|
|
||||||
## v.3.0.4
|
## v.3.0.4
|
||||||
* Добавлена проверка группы пользователя в заказе при редактировании
|
* Added checking the user group in the order when editing
|
||||||
* Добавлена передача скидки по бонусным баллам
|
* Added transfer of discount for bonus points
|
||||||
|
|
||||||
## v.3.0.3
|
## v.3.0.3
|
||||||
* Исправлена ошибка с изменением пароля пользователя
|
* Fixed a bug with changing the user's password
|
||||||
|
|
||||||
## v.3.0.2
|
## v.3.0.2
|
||||||
* Улучшена механика выгрузки изменений из RetailCRM на сайт
|
* Improved the mechanics of uploading changes from RetailCRM to the site
|
||||||
* Улучшена механика выборки типов доставки на сайте
|
* Improved the mechanics of selecting delivery types on the site
|
||||||
* Добавлена возможность периодической выгрузки акционных цен для товаров
|
* Added the ability to periodically upload promotional prices for products
|
||||||
* Улучшена совместимость с Opencart 3.0
|
* Improved compatibility with Opencart 3.0
|
||||||
|
|
||||||
## v.2.4.3
|
## v.2.4.3
|
||||||
* Устранены некоторые баги, добавлен вывод ошибок при выгрузке единичных заказов
|
* Minor bug fixes, added error output when uploading individual orders
|
||||||
|
|
||||||
## v.2.4.2
|
## v.2.4.2
|
||||||
* Улучшена синхронизация кастомных полей
|
* Improved synchronization of custom fields
|
||||||
* Добавлены настройки дефолтных способов доставки и оплаты
|
* Added settings for default delivery and payment types
|
||||||
* Улучшена настройка Daemon Collector
|
* Improved Daemon Collector configuration
|
||||||
* Доработан шаблон twig для совместимости с Opencart 3.0
|
* Improved the twig template for compatibility with Opencart 3.0
|
||||||
|
|
||||||
## v.2.4.1
|
## v.2.4.1
|
||||||
* Исправлена работа истории (доработана обработка адресов, добавлена обработка заказов с пустыми полями, доработана история по клиентам)
|
* Fixed history of changes (improved address processing, added order processing with empty fields, improved customer history)
|
||||||
* История теперь синхронизируется по sinceId
|
* History is now synced by sinceId
|
||||||
* Проверка доступных версий API через метод /api/versions
|
* Checking available API versions using the /api/versions method
|
||||||
* Добавлена возможность сопоставления кастомных полей(для API v5)
|
* Added the ability to map custom fields (for API V5)
|
||||||
|
|
||||||
## v.2.4.0
|
## v.2.4.0
|
||||||
* Добавлена возможность работы на 3 версиях API (v3, v4, v5)
|
* Added the ability to work on 3 API versions (v3, v4, v5)
|
||||||
* Добавлена совместимость с Opencart 3.0
|
* Added compatibility with Opencart 3.0
|
||||||
|
|
||||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2015 RetailDriver LLC
|
Copyright (c) 2015-2021 RetailDriver LLC
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
20
Makefile
20
Makefile
|
@ -1,5 +1,5 @@
|
||||||
FILE = $(TRAVIS_BUILD_DIR)/VERSION
|
ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||||
VERSION = `cat $(FILE)`
|
VERSION = `cat $(ROOT_DIR)/VERSION`
|
||||||
ARCHIVE_NAME = '/tmp/retailcrm-'$(VERSION)'.ocmod.zip'
|
ARCHIVE_NAME = '/tmp/retailcrm-'$(VERSION)'.ocmod.zip'
|
||||||
|
|
||||||
.PHONY: coverage
|
.PHONY: coverage
|
||||||
|
@ -17,11 +17,8 @@ delete_archive:
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
mkdir coverage
|
mkdir coverage
|
||||||
# Change MySQL root password
|
composer require --dev beyondit/opencart-test-suite:~$(TEST_SUITE)
|
||||||
echo "USE mysql;\nUPDATE user SET password=PASSWORD('root') WHERE user='root';\nFLUSH PRIVILEGES;\n" | mysql -u root
|
composer opencart:install
|
||||||
composer require --dev beyondit/opencart-test-suite ~$(TEST_SUITE)
|
|
||||||
composer require --dev opencart/opencart $(OPENCART)
|
|
||||||
composer setup
|
|
||||||
bin/robo --load-from tests/RoboFile.php project:deploy
|
bin/robo --load-from tests/RoboFile.php project:deploy
|
||||||
(php -S localhost:80 -t www &) 2> /dev/null > /dev/null
|
(php -S localhost:80 -t www &) 2> /dev/null > /dev/null
|
||||||
sleep 2
|
sleep 2
|
||||||
|
@ -34,8 +31,7 @@ robo_deploy:
|
||||||
|
|
||||||
run:
|
run:
|
||||||
composer require --dev beyondit/opencart-test-suite ~$(TEST_SUITE)
|
composer require --dev beyondit/opencart-test-suite ~$(TEST_SUITE)
|
||||||
composer require --dev opencart/opencart $(OPENCART)
|
composer opencart:install
|
||||||
composer setup
|
|
||||||
bin/robo --load-from tests/RoboFile.php project:deploy
|
bin/robo --load-from tests/RoboFile.php project:deploy
|
||||||
|
|
||||||
run_test: run
|
run_test: run
|
||||||
|
@ -45,3 +41,9 @@ run_test: run
|
||||||
|
|
||||||
test: robo_deploy
|
test: robo_deploy
|
||||||
composer test
|
composer test
|
||||||
|
|
||||||
|
phpcs-config:
|
||||||
|
bin/phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility
|
||||||
|
|
||||||
|
phpcomp: phpcs-config
|
||||||
|
@bin/phpcs -s -p ./src --standard=PHPCompatibility --runtime-set testVersion 7.3-7.4
|
||||||
|
|
46
README.md
46
README.md
|
@ -1,12 +1,12 @@
|
||||||
[](https://travis-ci.org/retailcrm/opencart-module)
|
[](https://github.com/retailcrm/opencart-module/actions)
|
||||||
[](https://codecov.io/gh/retailcrm/opencart-module)
|
[](https://codecov.io/gh/retailcrm/opencart-module)
|
||||||
[](https://github.com/retailcrm/opencart-module/releases)
|
[](https://github.com/retailcrm/opencart-module/releases)
|
||||||
[](https://php.net/)
|
[](https://php.net/)
|
||||||
|
|
||||||
Opencart module
|
Opencart module
|
||||||
===============
|
===============
|
||||||
|
|
||||||
Module allows integrate CMS Opencart >= 2.3 with [retailCRM](http://retailcrm.pro)
|
This module allows to integrate CMS Opencart >= 2.3 with [RetailCRM](https://retailcrm.pro).
|
||||||
|
|
||||||
### Previous versions:
|
### Previous versions:
|
||||||
|
|
||||||
|
@ -16,51 +16,59 @@ Module allows integrate CMS Opencart >= 2.3 with [retailCRM](http://retailcrm.pr
|
||||||
|
|
||||||
#### Features:
|
#### Features:
|
||||||
|
|
||||||
* Export orders to retailCRM & fetch changes back
|
* Export orders to RetailCRM & receive changes from RetailCRM.
|
||||||
* Export product catalog into [ICML](http://www.retailcrm.pro/docs/Developers/ICML) format
|
* Export product catalog to the [ICML](https://help.retailcrm.pro/Developers/ICML) format.
|
||||||
|
|
||||||
#### Install
|
#### Install
|
||||||
|
|
||||||
Copy files to the site root
|
**Note:** `/path/to/your/site` is just a placeholder. You should replace it with the actual path to your site root in the examples below. The module won't work if you'll use those examples without changing the path placeholder.
|
||||||
|
|
||||||
|
Copy module files to the site root (replace `/path/to/your/site` with the actual path to your site):
|
||||||
|
|
||||||
```
|
```
|
||||||
unzip master.zip
|
unzip master.zip
|
||||||
cp -r opencart-module/* /path/to/site/root
|
cp -r opencart-module/src/* /path/to/your/site
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Setup
|
#### Setup
|
||||||
|
|
||||||
* Go to Admin -> Extensions -> Modules -> retailCRM
|
* Go to Admin -> Extensions -> Modules -> RetailCRM
|
||||||
* Fill you api url & api key
|
* Fill you API URL & API key
|
||||||
* Specify directories matching
|
* Specify directories matching
|
||||||
|
|
||||||
#### Migrating to 4.* from early modules versions
|
#### Migrating to 4.* from early modules versions
|
||||||
|
|
||||||
Before you copy the files of module you will to remove the directory `path/to/opencart/system/library/retailcrm`
|
It's necessary to remove the `/path/to/your/site/system/library/retailcrm` before copying current module into your site.
|
||||||
|
|
||||||
#### Getting changes in orders
|
#### Getting changes in orders
|
||||||
|
|
||||||
Add to cron:
|
Add to cron (replace `/path/to/your/site` with the actual path to your site):
|
||||||
|
|
||||||
```
|
```
|
||||||
*/5 * * * * /usr/bin/php /path/to/opencart/system/library/retailcrm/cron/history.php >> /path/to/opencart/system/storage/logs/cronjob_history.log 2>&1
|
*/5 * * * * /usr/bin/php /path/to/your/site/system/library/retailcrm/cron/history.php >> /path/to/your/site/system/storage/logs/cronjob_history.log 2>&1
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Setting product catalog export
|
#### Setting product catalog export
|
||||||
|
|
||||||
Add to cron:
|
Add to cron (replace `/path/to/your/site` with the actual path to your site):
|
||||||
|
|
||||||
```
|
```
|
||||||
* */4 * * * /usr/bin/php /path/to/opencart/system/library/retailcrm/cron/icml.php >> /path/to/opencart/system/storage/logs/cronjob_icml.log 2>&1
|
* */4 * * * /usr/bin/php /path/to/your/site/system/library/retailcrm/cron/icml.php >> /path/to/your/site/system/storage/logs/cronjob_icml.log 2>&1
|
||||||
```
|
```
|
||||||
|
|
||||||
Your export file will be available by following url
|
Your export file should be available by following url:
|
||||||
|
|
||||||
```
|
```
|
||||||
http://youropencartsite.com/retailcrm.xml
|
http://youropencartsite.com/retailcrm.xml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Replace `youropencartsite.com` with your site domain and `http` with your site scheme.
|
||||||
|
|
||||||
#### Export existing orders and customers
|
#### Export existing orders and customers
|
||||||
|
|
||||||
You want to run this command onecly:
|
Run this command (replace `/path/to/your/site` with the actual path to your site):
|
||||||
/usr/bin/php /path/to/opencart/system/library/retailcrm/cron/export.php
|
```sh
|
||||||
|
/usr/bin/php /path/to/your/site/system/library/retailcrm/cron/export.php
|
||||||
|
```
|
||||||
|
|
||||||
|
You should run this command only once.
|
||||||
|
|
77
README.ru.md
77
README.ru.md
|
@ -1,77 +0,0 @@
|
||||||
Opencart module
|
|
||||||
===============
|
|
||||||
|
|
||||||
Модуль интеграции CMS Opencart >= 2.3 c [retailCRM](https://retailcrm.ru)
|
|
||||||
|
|
||||||
Информация о [кастомизации](https://github.com/retailcrm/opencart-module/wiki/%D0%9A%D0%B0%D1%81%D1%82%D0%BE%D0%BC%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F-%D0%B8%D0%BD%D1%82%D0%B5%D0%B3%D1%80%D0%B0%D1%86%D0%B8%D0%BE%D0%BD%D0%BD%D0%BE%D0%B3%D0%BE-%D0%BF%D0%BB%D0%B0%D0%B3%D0%B8%D0%BD%D0%B0)
|
|
||||||
|
|
||||||
### Предыдущие версии:
|
|
||||||
|
|
||||||
[v1.x](https://github.com/retailcrm/opencart-module/tree/v1.x)
|
|
||||||
|
|
||||||
[v2.x (2.0, 2.1, 2.2)](https://github.com/retailcrm/opencart-module/tree/v2.2)
|
|
||||||
|
|
||||||
#### Модуль позволяет:
|
|
||||||
|
|
||||||
* Экспортировать в retailCRM данные о заказах и клиентах и получать обратно изменения по этим данным
|
|
||||||
* Синхронизировать справочники (способы доставки и оплаты, статусы заказов и т.п.)
|
|
||||||
* Выгружать каталог товаров в формате [ICML](http://www.retailcrm.ru/docs/Developers/ICML)
|
|
||||||
|
|
||||||
#### Установка
|
|
||||||
|
|
||||||
Установите модуль скопировав необходимые файлы в корень сайта
|
|
||||||
|
|
||||||
```
|
|
||||||
unzip master.zip
|
|
||||||
cp -r opencart-module/* /path/to/site/root
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Обновление до 4.* с более ранних версий модуля
|
|
||||||
|
|
||||||
Перед копированием файлов модуля необходимо удалить директорию `path/to/opencart/system/library/retailcrm`
|
|
||||||
|
|
||||||
#### Активируйте модуль
|
|
||||||
|
|
||||||
В списке модулей нажмите "Установить"
|
|
||||||
|
|
||||||
#### Настройте параметры интеграции
|
|
||||||
|
|
||||||
На странице настроек модуля укажите URL retailCRM и ключ авторизации, после сохранения этих данных укажите соответствия справочников типов доставок, оплат и статусов заказа.
|
|
||||||
|
|
||||||
#### Получение измений из retailCRM
|
|
||||||
|
|
||||||
Для получения изменений и новых данных добавьте в cron следующую запись:
|
|
||||||
|
|
||||||
```
|
|
||||||
*/5 * * * * /usr/bin/php /path/to/opencart/system/library/retailcrm/cron/history.php >> /path/to/opencart/system/storage/logs/cronjob_history.log 2>&1
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Настройка экспорта каталога
|
|
||||||
|
|
||||||
Для периодической выгрузки каталога добавьте в cron следующую запись:
|
|
||||||
|
|
||||||
```
|
|
||||||
* */4 * * * /usr/bin/php /path/to/opencart/system/library/retailcrm/cron/icml.php >> /path/to/opencart/system/storage/logs/cronjob_icml.log 2>&1
|
|
||||||
```
|
|
||||||
|
|
||||||
В настройках retailCRM установите путь к файлу выгрузки
|
|
||||||
|
|
||||||
```
|
|
||||||
http://youropencartsite.com/retailcrm.xml
|
|
||||||
```
|
|
||||||
#### Настройка выгрузки акционных цен
|
|
||||||
|
|
||||||
Для периодической выгрузки акционных цен в CRM в настройках модуля укажите тип цены, в который необходимо выгружать акционные цены, в крон добавьте следующую запись
|
|
||||||
|
|
||||||
```
|
|
||||||
0 0 * * * /usr/bin/php /path/to/opencart/system/library/retailcrm/cron/prices.php >> /path/to/opencart/system/storage/logs/cronjob_prices.log 2>&1
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Выгрузка существующих заказов и покупателей
|
|
||||||
|
|
||||||
Запустите команду единожды:
|
|
||||||
/usr/bin/php /path/to/opencart/system/library/retailcrm/cron/export.php
|
|
||||||
|
|
||||||
#### Кастомизация моделей
|
|
||||||
|
|
||||||
Для создания кастомных классов скопируйте файл модели в директорию custom, в новом файле измените название класса с "ModelExtensionRetailcrmFilename" на "ModelExtensionRetailcrmCustomFilename", где "Filename" - название файла с заглавной буквы. После этого модуль будет использовать методы кастомного класса.
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
4.0.0
|
4.1.19
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "retailcrm/opencart-module",
|
"name": "retailcrm/opencart-module",
|
||||||
"description": "Integration module for Opencart & retailCRM",
|
"description": "Integration module for Opencart & RetailCRM",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "RetailDriverLLC",
|
"name": "RetailDriverLLC",
|
||||||
"email": "integration@retailcrm.ru"
|
"email": "support@retailcrm.pro"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"config": {
|
"config": {
|
||||||
|
@ -25,12 +25,14 @@
|
||||||
"@test-catalog",
|
"@test-catalog",
|
||||||
"@test-system"
|
"@test-system"
|
||||||
],
|
],
|
||||||
"setup" : "bin/robo --load-from tests/RoboFile.php opencart:setup"
|
"opencart:install" : "bin/robo --load-from tests/RoboFile.php opencart:install"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-json": "*"
|
"ext-json": "*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"consolidation/robo": "~1.0"
|
"consolidation/robo": "~1.0",
|
||||||
|
"phpcompatibility/php-compatibility": "^9.3",
|
||||||
|
"beyondit/opencart-test-suite": "~3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
6
doc/Update module.md
Normal file
6
doc/Update module.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
### Обновление версии модуля
|
||||||
|
|
||||||
|
Для обновления версии модуля необходимо обновить следующие файлы:
|
||||||
|
* VERSION
|
||||||
|
* CHANGELOG.md
|
||||||
|
* src/upload/admin/controller/extension/module/retailcrm.php
|
|
@ -1,17 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
use retailcrm\Retailcrm;
|
||||||
* Class ControllerModule
|
|
||||||
*
|
|
||||||
* @category RetailCrm
|
|
||||||
* @package RetailCrm
|
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
|
||||||
*/
|
|
||||||
class ControllerExtensionModuleRetailcrm extends Controller
|
class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
{
|
{
|
||||||
private $_error = array();
|
private $_error = [];
|
||||||
protected $log, $statuses, $payments, $deliveryTypes, $retailcrmApiClient, $moduleTitle, $tokenTitle;
|
protected $log, $statuses, $payments, $deliveryTypes, $retailcrmApiClient, $moduleTitle, $tokenTitle;
|
||||||
public $children, $template;
|
public $children, $template;
|
||||||
|
|
||||||
|
@ -34,10 +27,10 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
|
|
||||||
$this->model_setting_setting->editSetting(
|
$this->model_setting_setting->editSetting(
|
||||||
$this->moduleTitle,
|
$this->moduleTitle,
|
||||||
array(
|
[
|
||||||
$this->moduleTitle . '_status' => 1,
|
$this->moduleTitle . '_status' => 1,
|
||||||
$this->moduleTitle . '_country' => array($this->config->get('config_country_id'))
|
$this->moduleTitle . '_country' => [$this->config->get('config_country_id')]
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addEvents();
|
$this->addEvents();
|
||||||
|
@ -68,7 +61,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
$this->uninstall_collector();
|
$this->uninstall_collector();
|
||||||
$this->model_setting_setting->editSetting(
|
$this->model_setting_setting->editSetting(
|
||||||
$this->moduleTitle,
|
$this->moduleTitle,
|
||||||
array($this->moduleTitle . '_status' => 0)
|
[$this->moduleTitle . '_status' => 0]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +81,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
$this->loadModels();
|
$this->loadModels();
|
||||||
$this->load->model('setting/setting');
|
$this->load->model('setting/setting');
|
||||||
$this->{'model_' . $this->modelExtension}->install('analytics', 'daemon_collector');
|
$this->{'model_' . $this->modelExtension}->install('analytics', 'daemon_collector');
|
||||||
$this->model_setting_setting->editSetting($collector, array($collector . '_status' => 1));
|
$this->model_setting_setting->editSetting($collector, [$collector . '_status' => 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,10 +94,38 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
$collector = $this->getCollectorTitle();
|
$collector = $this->getCollectorTitle();
|
||||||
$this->loadModels();
|
$this->loadModels();
|
||||||
$this->load->model('setting/setting');
|
$this->load->model('setting/setting');
|
||||||
$this->model_setting_setting->editSetting($collector, array($collector . '_status' => 0));
|
$this->model_setting_setting->editSetting($collector, [$collector . '_status' => 0]);
|
||||||
$this->{'model_' . $this->modelExtension}->uninstall('analytics', 'daemon_collector');
|
$this->{'model_' . $this->modelExtension}->uninstall('analytics', 'daemon_collector');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install OnlineConsultant method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function install_consultant()
|
||||||
|
{
|
||||||
|
$consultant = $this->getConsultantTitle();
|
||||||
|
$this->loadModels();
|
||||||
|
$this->load->model('setting/setting');
|
||||||
|
$this->{'model_' . $this->modelExtension}->install('analytics', 'online_consultant');
|
||||||
|
$this->model_setting_setting->editSetting($consultant, [$consultant . '_status' => 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uninstall OnlineConsultant method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function uninstall_consultant()
|
||||||
|
{
|
||||||
|
$consultant = $this->getConsultantTitle();
|
||||||
|
$this->loadModels();
|
||||||
|
$this->load->model('setting/setting');
|
||||||
|
$this->model_setting_setting->editSetting($consultant, [$consultant . '_status' => 0]);
|
||||||
|
$this->{'model_' . $this->modelExtension}->uninstall('analytics', 'online_consultant');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup page
|
* Setup page
|
||||||
*
|
*
|
||||||
|
@ -124,6 +145,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
$this->document->addStyle('/admin/view/stylesheet/retailcrm.css');
|
$this->document->addStyle('/admin/view/stylesheet/retailcrm.css');
|
||||||
|
|
||||||
$collector = $this->getCollectorTitle();
|
$collector = $this->getCollectorTitle();
|
||||||
|
$consultant = $this->getConsultantTitle();
|
||||||
$history_setting = $this->model_setting_setting->getSetting('retailcrm_history');
|
$history_setting = $this->model_setting_setting->getSetting('retailcrm_history');
|
||||||
|
|
||||||
if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
|
if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
|
||||||
|
@ -144,6 +166,12 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
$this->uninstall_collector();
|
$this->uninstall_collector();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->request->post[$this->moduleTitle . '_online_consultant_active'] == 1) {
|
||||||
|
$this->install_consultant();
|
||||||
|
} elseif ($this->request->post[$this->moduleTitle . '_online_consultant_active'] == 0) {
|
||||||
|
$this->uninstall_consultant();
|
||||||
|
}
|
||||||
|
|
||||||
if (parse_url($this->request->post[$this->moduleTitle . '_url'])) {
|
if (parse_url($this->request->post[$this->moduleTitle . '_url'])) {
|
||||||
$crm_url = parse_url($this->request->post[$this->moduleTitle . '_url'], PHP_URL_HOST);
|
$crm_url = parse_url($this->request->post[$this->moduleTitle . '_url'], PHP_URL_HOST);
|
||||||
$this->request->post[$this->moduleTitle . '_url'] = 'https://' . $crm_url;
|
$this->request->post[$this->moduleTitle . '_url'] = 'https://' . $crm_url;
|
||||||
|
@ -160,42 +188,21 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
$this->request->post
|
$this->request->post
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!isset($history_setting['retailcrm_history_orders']) && !isset($history_setting['retailcrm_history_customers'])) {
|
if (
|
||||||
|
!isset($history_setting['retailcrm_history_orders'])
|
||||||
|
&& !isset($history_setting['retailcrm_history_customers'])
|
||||||
|
) {
|
||||||
$api = $this->retailcrm->getApiClient(
|
$api = $this->retailcrm->getApiClient(
|
||||||
$this->request->post[$this->moduleTitle . '_url'],
|
$this->request->post[$this->moduleTitle . '_url'],
|
||||||
$this->request->post[$this->moduleTitle . '_apikey']
|
$this->request->post[$this->moduleTitle . '_apikey']
|
||||||
);
|
);
|
||||||
|
|
||||||
$ordersHistory = $api->ordersHistory();
|
|
||||||
|
|
||||||
if ($ordersHistory && $ordersHistory->isSuccessful() && !empty($ordersHistory['history'])) {
|
|
||||||
$ordersHistory = $api->ordersHistory(array(), $ordersHistory['pagination']['totalPageCount']);
|
|
||||||
|
|
||||||
if ($ordersHistory && $ordersHistory->isSuccessful()) {
|
|
||||||
$ordersHistoryArr = $ordersHistory['history'];
|
|
||||||
$lastChangeOrders = end($ordersHistoryArr);
|
|
||||||
$sinceIdOrders = $lastChangeOrders['id'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$customersHistory = $api->customersHistory();
|
|
||||||
|
|
||||||
if ($customersHistory && $customersHistory->isSuccessful() && !empty($customersHistory['history'])) {
|
|
||||||
$customersHistory = $api->customersHistory(array(), $customersHistory['pagination']['totalPageCount']);
|
|
||||||
|
|
||||||
if ($customersHistory && $customersHistory->isSuccessful()) {
|
|
||||||
$customersHistoryArr = $customersHistory['history'];
|
|
||||||
$lastChangeCustomers = end($customersHistoryArr);
|
|
||||||
$sinceIdCustomers = $lastChangeCustomers['id'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->model_setting_setting->editSetting(
|
$this->model_setting_setting->editSetting(
|
||||||
'retailcrm_history',
|
'retailcrm_history',
|
||||||
array(
|
[
|
||||||
'retailcrm_history_orders' => isset($sinceIdOrders) ? $sinceIdOrders : 1,
|
'retailcrm_history_orders' => $this->getHistorySinceId($api, 'ordersHistory'),
|
||||||
'retailcrm_history_customers' => isset($sinceIdCustomers) ? $sinceIdCustomers : 1
|
'retailcrm_history_customers' => $this->getHistorySinceId($api, 'customersHistory'),
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,12 +223,12 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
$this->model_setting_setting->editSetting(
|
$this->model_setting_setting->editSetting(
|
||||||
'retailcrm_setting',
|
'retailcrm_setting',
|
||||||
array(
|
[
|
||||||
'retailcrm_setting_active_in_crm' => true,
|
'retailcrm_setting_active_in_crm' => true,
|
||||||
'retailcrm_setting_client_id' => $clientId,
|
'retailcrm_setting_client_id' => $clientId,
|
||||||
'retailcrm_setting_url' => $this->request->post[$this->moduleTitle . '_url'],
|
'retailcrm_setting_url' => $this->request->post[$this->moduleTitle . '_url'],
|
||||||
'retailcrm_setting_key' => $this->request->post[$this->moduleTitle . '_apikey']
|
'retailcrm_setting_key' => $this->request->post[$this->moduleTitle . '_apikey']
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,7 +242,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
$this->response->redirect($redirect);
|
$this->response->redirect($redirect);
|
||||||
}
|
}
|
||||||
|
|
||||||
$text_strings = array(
|
$text_strings = [
|
||||||
'heading_title',
|
'heading_title',
|
||||||
'text_enabled',
|
'text_enabled',
|
||||||
'text_disabled',
|
'text_disabled',
|
||||||
|
@ -243,7 +250,6 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
'button_cancel',
|
'button_cancel',
|
||||||
'text_notice',
|
'text_notice',
|
||||||
'retailcrm_title',
|
'retailcrm_title',
|
||||||
'retailcrm_apiversion',
|
|
||||||
'retailcrm_url',
|
'retailcrm_url',
|
||||||
'retailcrm_apikey',
|
'retailcrm_apikey',
|
||||||
'retailcrm_base_settings',
|
'retailcrm_base_settings',
|
||||||
|
@ -265,6 +271,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
'general_tab_text',
|
'general_tab_text',
|
||||||
'references_tab_text',
|
'references_tab_text',
|
||||||
'collector_tab_text',
|
'collector_tab_text',
|
||||||
|
'consultant_tab_text',
|
||||||
'logs_tab_text',
|
'logs_tab_text',
|
||||||
'text_yes',
|
'text_yes',
|
||||||
'text_no',
|
'text_no',
|
||||||
|
@ -294,49 +301,58 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
'special_price',
|
'special_price',
|
||||||
'order_number',
|
'order_number',
|
||||||
'text_order_number',
|
'text_order_number',
|
||||||
'text_currency',
|
'summ_around',
|
||||||
|
'text_summ_around',
|
||||||
|
'icml_settings',
|
||||||
|
'icml_service_enabled_label',
|
||||||
|
'icml_service_description',
|
||||||
'text_currency_label',
|
'text_currency_label',
|
||||||
'status_changes',
|
'status_changes',
|
||||||
'text_status_changes',
|
'text_status_changes',
|
||||||
'text_lenght',
|
'text_lenght',
|
||||||
'text_lenght_label',
|
'text_lenght_label',
|
||||||
'corporate_enabled_label'
|
'corporate_enabled_label',
|
||||||
);
|
'entry_code',
|
||||||
|
'entry_status',
|
||||||
|
'text_retailcrm_discount',
|
||||||
|
'text_retailcrm_label_discount',
|
||||||
|
'default_retailcrm_label_discount',
|
||||||
|
'sum_payment',
|
||||||
|
'text_sum_payment',
|
||||||
|
];
|
||||||
|
|
||||||
$_data = &$data;
|
$_data = &$data;
|
||||||
|
|
||||||
|
$_data['module_version'] = Retailcrm::VERSION_MODULE;
|
||||||
|
|
||||||
foreach ($text_strings as $text) {
|
foreach ($text_strings as $text) {
|
||||||
$_data[$text] = $this->language->get($text);
|
$_data[$text] = $this->language->get($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
$_data['currencies'] = $this->model_localisation_currency->getCurrencies(0);
|
$_data['currencies'] = $this->model_localisation_currency->getCurrencies(0);
|
||||||
$_data['retailcrm_errors'] = array();
|
$_data['retailcrm_errors'] = [];
|
||||||
$_data['saved_settings'] = $this->model_setting_setting
|
$_data['saved_settings'] = $this->model_setting_setting
|
||||||
->getSetting($this->moduleTitle);
|
->getSetting($this->moduleTitle);
|
||||||
|
|
||||||
$url = isset($_data['saved_settings'][$this->moduleTitle . '_url'])
|
$url = $_data['saved_settings'][$this->moduleTitle . '_url'] ?? null;
|
||||||
? $_data['saved_settings'][$this->moduleTitle . '_url']
|
$key = $_data['saved_settings'][$this->moduleTitle . '_apikey'] ?? null;
|
||||||
: null;
|
|
||||||
$key = isset($_data['saved_settings'][$this->moduleTitle . '_apikey'])
|
|
||||||
? $_data['saved_settings'][$this->moduleTitle . '_apikey']
|
|
||||||
: null;
|
|
||||||
$apiVersion = isset($_data['saved_settings'][$this->moduleTitle . '_apiversion'])
|
|
||||||
? $_data['saved_settings'][$this->moduleTitle . '_apiversion']
|
|
||||||
: null;
|
|
||||||
|
|
||||||
if (!empty($url) && !empty($key)) {
|
if (!empty($url) && !empty($key)) {
|
||||||
|
$this->validate($url, $key);
|
||||||
|
|
||||||
$_data['delivery'] = $this->model_extension_retailcrm_references
|
$site = $this->model_extension_retailcrm_references->getApiSite();
|
||||||
->getDeliveryTypes();
|
$_data['delivery'] = $this->getAvailableTypes(
|
||||||
|
$site,
|
||||||
|
$this->model_extension_retailcrm_references->getDeliveryTypes()
|
||||||
|
);
|
||||||
|
$_data['payments'] = $this->getAvailableTypes(
|
||||||
|
$site,
|
||||||
|
$this->model_extension_retailcrm_references->getPaymentTypes()
|
||||||
|
);
|
||||||
$_data['statuses'] = $this->model_extension_retailcrm_references
|
$_data['statuses'] = $this->model_extension_retailcrm_references
|
||||||
->getOrderStatuses();
|
->getOrderStatuses();
|
||||||
$_data['payments'] = $this->model_extension_retailcrm_references
|
$_data['customFields'] = $this->model_extension_retailcrm_references
|
||||||
->getPaymentTypes();
|
->getCustomFields();
|
||||||
|
|
||||||
if ($apiVersion == 'v5') {
|
|
||||||
$_data['customFields'] = $this->model_extension_retailcrm_references
|
|
||||||
->getCustomFields();
|
|
||||||
}
|
|
||||||
|
|
||||||
$_data['lenghts'] = $this->model_localisation_length_class->getLengthClasses();
|
$_data['lenghts'] = $this->model_localisation_length_class->getLengthClasses();
|
||||||
$_data['priceTypes'] = $this->model_extension_retailcrm_references
|
$_data['priceTypes'] = $this->model_extension_retailcrm_references
|
||||||
|
@ -344,9 +360,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
$_data['customerGroups'] = $this->model_customer_customer_group->getCustomerGroups();
|
$_data['customerGroups'] = $this->model_customer_customer_group->getCustomerGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
$config_data = array(
|
$config_data = [$this->moduleTitle . '_status'];
|
||||||
$this->moduleTitle . '_status'
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($config_data as $conf) {
|
foreach ($config_data as $conf) {
|
||||||
if (isset($this->request->post[$conf])) {
|
if (isset($this->request->post[$conf])) {
|
||||||
|
@ -356,40 +370,35 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->_error['warning'])) {
|
$_data['error_warning'] = $this->_error['warning'] ?? '';
|
||||||
$_data['error_warning'] = $this->_error['warning'];
|
$_data['breadcrumbs'] = [];
|
||||||
} else {
|
|
||||||
$_data['error_warning'] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$_data['breadcrumbs'] = array();
|
$_data['breadcrumbs'][] = [
|
||||||
|
|
||||||
$_data['breadcrumbs'][] = array(
|
|
||||||
'text' => $this->language->get('text_home'),
|
'text' => $this->language->get('text_home'),
|
||||||
'href' => $this->url->link(
|
'href' => $this->url->link(
|
||||||
'common/dashboard',
|
'common/dashboard',
|
||||||
$this->tokenTitle . '=' . $this->session->data[$this->tokenTitle], 'SSL'
|
$this->tokenTitle . '=' . $this->session->data[$this->tokenTitle], 'SSL'
|
||||||
),
|
),
|
||||||
'separator' => false
|
'separator' => false
|
||||||
);
|
];
|
||||||
|
|
||||||
$_data['breadcrumbs'][] = array(
|
$_data['breadcrumbs'][] = [
|
||||||
'text' => $this->language->get('text_module'),
|
'text' => $this->language->get('text_module'),
|
||||||
'href' => $this->url->link(
|
'href' => $this->url->link(
|
||||||
'extension/extension',
|
'extension/extension',
|
||||||
$this->tokenTitle . '=' . $this->session->data[$this->tokenTitle], 'SSL'
|
$this->tokenTitle . '=' . $this->session->data[$this->tokenTitle], 'SSL'
|
||||||
),
|
),
|
||||||
'separator' => ' :: '
|
'separator' => ' :: '
|
||||||
);
|
];
|
||||||
|
|
||||||
$_data['breadcrumbs'][] = array(
|
$_data['breadcrumbs'][] = [
|
||||||
'text' => $this->language->get('retailcrm_title'),
|
'text' => $this->language->get('retailcrm_title'),
|
||||||
'href' => $this->url->link(
|
'href' => $this->url->link(
|
||||||
'extension/module/retailcrm',
|
'extension/module/retailcrm',
|
||||||
$this->tokenTitle . '=' . $this->session->data[$this->tokenTitle], 'SSL'
|
$this->tokenTitle . '=' . $this->session->data[$this->tokenTitle], 'SSL'
|
||||||
),
|
),
|
||||||
'separator' => ' :: '
|
'separator' => ' :: '
|
||||||
);
|
];
|
||||||
|
|
||||||
$_data['action'] = $this->url->link(
|
$_data['action'] = $this->url->link(
|
||||||
'extension/module/retailcrm',
|
'extension/module/retailcrm',
|
||||||
|
@ -401,7 +410,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
$this->tokenTitle . '=' . $this->session->data[$this->tokenTitle], 'SSL'
|
$this->tokenTitle . '=' . $this->session->data[$this->tokenTitle], 'SSL'
|
||||||
);
|
);
|
||||||
|
|
||||||
$_data['modules'] = array();
|
$_data['modules'] = [];
|
||||||
|
|
||||||
if (isset($this->request->post['retailcrm_module'])) {
|
if (isset($this->request->post['retailcrm_module'])) {
|
||||||
$_data['modules'] = $this->request->post['retailcrm_module'];
|
$_data['modules'] = $this->request->post['retailcrm_module'];
|
||||||
|
@ -425,11 +434,11 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
$_data['export_file'] = true;
|
$_data['export_file'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$collectorFields = array(
|
$collectorFields = [
|
||||||
'name' => $this->language->get('field_name'),
|
'name' => $this->language->get('field_name'),
|
||||||
'email' => $this->language->get('field_email'),
|
'email' => $this->language->get('field_email'),
|
||||||
'phone' => $this->language->get('field_phone')
|
'phone' => $this->language->get('field_phone')
|
||||||
);
|
];
|
||||||
|
|
||||||
$_data['collectorFields'] = $collectorFields;
|
$_data['collectorFields'] = $collectorFields;
|
||||||
|
|
||||||
|
@ -548,20 +557,12 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
|
|
||||||
$this->response->setOutput(
|
$this->response->setOutput(
|
||||||
json_encode(
|
json_encode(
|
||||||
array(
|
['status_code' => $response->getStatusCode(), 'error_msg' => $error],
|
||||||
'status_code' => $response->getStatusCode(),
|
JSON_THROW_ON_ERROR
|
||||||
'error_msg' => $error
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->response->setOutput(
|
$this->response->setOutput(json_encode(['status_code' => $response->getStatusCode()]));
|
||||||
json_encode(
|
|
||||||
array(
|
|
||||||
'status_code' => $response->getStatusCode()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -581,7 +582,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
$this->model_extension_retailcrm_customer->uploadToCrm($customers, $this->retailcrm->getApiClient());
|
$this->model_extension_retailcrm_customer->uploadToCrm($customers, $this->retailcrm->getApiClient());
|
||||||
$orders = $this->model_sale_order->getOrders();
|
$orders = $this->model_sale_order->getOrders();
|
||||||
|
|
||||||
$fullOrders = array();
|
$fullOrders = [];
|
||||||
|
|
||||||
foreach ($orders as $order) {
|
foreach ($orders as $order) {
|
||||||
$fullOrder = $this->model_sale_order->getOrder($order['order_id']);
|
$fullOrder = $this->model_sale_order->getOrder($order['order_id']);
|
||||||
|
@ -624,39 +625,57 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function validate()
|
private function validate($apiUrl = null, $apiKey = null)
|
||||||
{
|
{
|
||||||
if (!empty($this->request->post[$this->moduleTitle . '_url']) && !empty($this->request->post[$this->moduleTitle . '_apikey'])) {
|
$warningMessage = '';
|
||||||
$apiClient = $this->retailcrm->getApiClient(
|
|
||||||
$this->request->post[$this->moduleTitle . '_url'],
|
$apiUrl = $this->request->post[$this->moduleTitle . '_url'] ?? $apiUrl;
|
||||||
$this->request->post[$this->moduleTitle . '_apikey']
|
$apiKey = $this->request->post[$this->moduleTitle . '_apikey'] ?? $apiKey;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ( !empty($apiUrl) && !empty($apiKey)) {
|
||||||
|
$apiClient = $this->retailcrm->getApiClient($apiUrl, $apiKey);
|
||||||
|
$response = $apiClient->sitesList();
|
||||||
|
|
||||||
|
if (empty($response['sites']) || !$response->isSuccessful()) {
|
||||||
|
$warningMessage = 'text_error_api_key';
|
||||||
|
} elseif (count($response['sites']) > 1) {
|
||||||
|
$warningMessage = 'text_error_api_key_site';
|
||||||
|
} else {
|
||||||
|
$site = current($response['sites']);
|
||||||
|
|
||||||
|
if ($this->config->get('config_currency') !== $site['currency']) {
|
||||||
|
$warningMessage = 'text_error_api_key_currency';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->user->hasPermission('modify', 'extension/module/retailcrm')) {
|
||||||
|
$this->_error['warning'] = $this->language->get('error_permission');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($this->request->post[$this->moduleTitle . '_collector']['custom']) &&
|
||||||
|
$this->request->post[$this->moduleTitle . '_collector']['custom_form'] == 1) {
|
||||||
|
$customField = $this->request->post[$this->moduleTitle . '_collector']['custom'];
|
||||||
|
|
||||||
|
if (empty($customField['name']) && empty($customField['email']) && empty($customField['phone'])) {
|
||||||
|
$this->_error['fields'] = $this->language->get('text_error_collector_fields');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$warningMessage = 'text_error_api_empty';
|
||||||
|
}
|
||||||
|
} catch (Throwable $exception) {
|
||||||
|
$warningMessage = sprintf(
|
||||||
|
'An error has occurred! In file: %s, on line: %s. Error message: %s',
|
||||||
|
$exception->getFile(), $exception->getLine(), $exception->getMessage()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $apiClient->apiVersions();
|
if ('' !== $warningMessage) {
|
||||||
|
$this->_error['warning'] = $this->language->get($warningMessage);
|
||||||
if (!$response || !$response->isSuccessful()) {
|
|
||||||
$this->_error['warning'] = $this->language->get('text_error_api');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->user->hasPermission('modify', 'extension/module/retailcrm')) {
|
return empty($this->_error);
|
||||||
$this->_error['warning'] = $this->language->get('error_permission');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($this->request->post[$this->moduleTitle . '_collector']['custom']) &&
|
|
||||||
$this->request->post[$this->moduleTitle . '_collector']['custom_form'] == 1) {
|
|
||||||
$customField = $this->request->post[$this->moduleTitle . '_collector']['custom'];
|
|
||||||
|
|
||||||
if (empty($customField['name']) && empty($customField['email']) && empty($customField['phone'])) {
|
|
||||||
$this->_error['fields'] = $this->language->get('text_error_collector_fields');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$this->_error) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -737,6 +756,22 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
return $title;
|
return $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get consultant module name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getConsultantTitle()
|
||||||
|
{
|
||||||
|
if (version_compare(VERSION, '3.0', '<')) {
|
||||||
|
$title = 'online_consultant';
|
||||||
|
} else {
|
||||||
|
$title = 'analytics_online_consultant';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $title;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check file size
|
* Check file size
|
||||||
*
|
*
|
||||||
|
@ -796,6 +831,13 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
'extension/module/retailcrm/customer_edit'
|
'extension/module/retailcrm/customer_edit'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->{'model_' . $this->modelEvent}
|
||||||
|
->addEvent(
|
||||||
|
$this->moduleTitle,
|
||||||
|
'catalog/model/account/customer/editNewsletter/after',
|
||||||
|
'extension/module/retailcrm/customer_edit_newsletter'
|
||||||
|
);
|
||||||
|
|
||||||
$this->{'model_' . $this->modelEvent}
|
$this->{'model_' . $this->modelEvent}
|
||||||
->addEvent(
|
->addEvent(
|
||||||
$this->moduleTitle,
|
$this->moduleTitle,
|
||||||
|
@ -853,7 +895,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activate/deactivate module in marketplace retailCRM
|
* Activate/deactivate module in marketplace RetailCRM
|
||||||
*
|
*
|
||||||
* @param \RetailcrmProxy $apiClient
|
* @param \RetailcrmProxy $apiClient
|
||||||
* @param string $clientId
|
* @param string $clientId
|
||||||
|
@ -869,15 +911,15 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
$name = 'Opencart';
|
$name = 'Opencart';
|
||||||
$accountUrl = $scheme . $this->request->server['HTTP_HOST'] . '/admin';
|
$accountUrl = $scheme . $this->request->server['HTTP_HOST'] . '/admin';
|
||||||
|
|
||||||
$configuration = array(
|
$configuration = [
|
||||||
'clientId' => $clientId,
|
'clientId' => $clientId,
|
||||||
'code' => $integrationCode . '-' . $clientId,
|
'code' => $integrationCode . '-' . $clientId,
|
||||||
'integrationCode' => $integrationCode,
|
'integrationCode' => $integrationCode,
|
||||||
'active' => $active,
|
'active' => $active,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'logo' => $logo,
|
'logo' => $logo,
|
||||||
'accountUrl' => $accountUrl
|
'accountUrl' => $accountUrl,
|
||||||
);
|
];
|
||||||
|
|
||||||
$response = $apiClient->integrationModulesEdit($configuration);
|
$response = $apiClient->integrationModulesEdit($configuration);
|
||||||
|
|
||||||
|
@ -891,4 +933,57 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getHistorySinceId($api, $method)
|
||||||
|
{
|
||||||
|
$lastSinceId = 0;
|
||||||
|
$startDate = new DateTime('-1 days');
|
||||||
|
$historyResponse = $api->$method(['startDate' => $startDate->format('Y-m-d H:i:s')]);
|
||||||
|
|
||||||
|
if (
|
||||||
|
!$historyResponse instanceof ApiResponse
|
||||||
|
|| !$historyResponse->isSuccessful()
|
||||||
|
|| empty($historyResponse['history'])
|
||||||
|
|| empty($historyResponse['pagination'])
|
||||||
|
) {
|
||||||
|
return $lastSinceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
$startPage = $historyResponse['pagination']['currentPage'];
|
||||||
|
$lastPage = $historyResponse['pagination']['totalPageCount'];
|
||||||
|
|
||||||
|
for ($startPage; $startPage <= $lastPage; ++$startPage) {
|
||||||
|
if ($historyResponse instanceof ApiResponse && !empty($historyResponse['history'])) {
|
||||||
|
$history = $historyResponse['history'];
|
||||||
|
$lastSinceId = end($history)['id'];
|
||||||
|
$historyResponse = $api->$method(['sinceId' => $lastSinceId]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $lastSinceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getAvailableTypes($availableSite, $types)
|
||||||
|
{
|
||||||
|
$result['opencart'] = $types['opencart'];
|
||||||
|
$result['retailcrm'] = [];
|
||||||
|
|
||||||
|
if (empty($availableSite)) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($types['retailcrm'] as $codeKey => $type) {
|
||||||
|
if ($type['active'] !== true) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($type['sites']) && !in_array($availableSite['code'], $type['sites'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result['retailcrm'][$codeKey] = $type;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Heading Goes here:
|
// Heading Goes here:
|
||||||
$_['heading_title'] = 'retailCRM';
|
$_['heading_title'] = 'RetailCRM';
|
||||||
$_['retailcrm_title'] = 'retailCRM';
|
$_['retailcrm_title'] = 'RetailCRM';
|
||||||
|
|
||||||
// Text
|
// Text
|
||||||
$_['text_module'] = 'Modules';
|
$_['text_module'] = 'Modules';
|
||||||
|
@ -13,15 +13,15 @@ $_['retailcrm_dict_settings'] = 'Configuration of directories correspondence'
|
||||||
$_['retailcrm_countries_settings'] = 'Setting of trade zones';
|
$_['retailcrm_countries_settings'] = 'Setting of trade zones';
|
||||||
$_['retailcrm_upload_order'] = 'Uploading one order';
|
$_['retailcrm_upload_order'] = 'Uploading one order';
|
||||||
$_['daemon_collector'] = 'Daemon Collector';
|
$_['daemon_collector'] = 'Daemon Collector';
|
||||||
|
$_['consultant_tab_text'] = 'Online Consultant';
|
||||||
$_['general_tab_text'] = 'Main';
|
$_['general_tab_text'] = 'Main';
|
||||||
$_['references_tab_text'] = 'Directories';
|
$_['references_tab_text'] = 'Directories';
|
||||||
$_['collector_tab_text'] = 'Daemon Collector';
|
$_['collector_tab_text'] = 'Daemon Collector';
|
||||||
$_['logs_tab_text'] = 'Logs';
|
$_['logs_tab_text'] = 'Logs';
|
||||||
$_['collector_custom_text'] = 'Configuration of form fields';
|
$_['collector_custom_text'] = 'Configuration of form fields';
|
||||||
$_['custom_fields_tab_text'] = 'Custom fields';
|
$_['custom_fields_tab_text'] = 'Custom fields';
|
||||||
$_['retailcrm_apiversion'] = 'API Version';
|
$_['retailcrm_url'] = 'URL of RetailCRM';
|
||||||
$_['retailcrm_url'] = 'URL of retailCRM';
|
$_['retailcrm_apikey'] = 'API key of RetailCRM';
|
||||||
$_['retailcrm_apikey'] = 'API key of retailCRM';
|
|
||||||
$_['corporate_enabled_label'] = 'Corporate customers support';
|
$_['corporate_enabled_label'] = 'Corporate customers support';
|
||||||
$_['collector_site_key'] = 'Site key';
|
$_['collector_site_key'] = 'Site key';
|
||||||
$_['special_price_settings'] = 'Setting of uploading promotion price';
|
$_['special_price_settings'] = 'Setting of uploading promotion price';
|
||||||
|
@ -50,11 +50,14 @@ $_['text_payment'] = 'Payment';
|
||||||
$_['text_shipping'] = 'Delivery';
|
$_['text_shipping'] = 'Delivery';
|
||||||
$_['text_orders_custom_fields'] = 'Custom fields of orders';
|
$_['text_orders_custom_fields'] = 'Custom fields of orders';
|
||||||
$_['text_customers_custom_fields'] = 'Custom fields of customers';
|
$_['text_customers_custom_fields'] = 'Custom fields of customers';
|
||||||
$_['text_error_collector_fields']= 'Fill in the names of fields of Demon Collector form';
|
$_['text_error_collector_fields'] = 'Fill in the names of fields of Demon Collector form';
|
||||||
$_['text_error_api'] = 'The selected API version is not available.';
|
$_['text_error_api_empty'] = 'The "RetailCRM URL" and "RetailCRM API key" fields cannot be empty, enter the correct value';
|
||||||
$_['text_error_custom_field'] = 'Create custom fields on a customer page in Opencart and retailCRM in order to set up their transfer';
|
$_['text_error_api_key'] = 'Invalid API key';
|
||||||
|
$_['text_error_api_key_site'] = 'API key with one-shop access required';
|
||||||
|
$_['text_error_api_key_currency'] = 'The currency of the site differs from the currency of the store in CRM. For the integration to work correctly, the currencies in CRM and CMS must match';
|
||||||
|
$_['text_error_custom_field'] = 'Create custom fields on a customer page in Opencart and RetailCRM in order to set up their transfer';
|
||||||
$_['text_error_cf_opencart'] = 'There are no custom fields in Opencart';
|
$_['text_error_cf_opencart'] = 'There are no custom fields in Opencart';
|
||||||
$_['text_error_cf_retailcrm'] = 'There are no custom fields in retailCRM';
|
$_['text_error_cf_retailcrm'] = 'There are no custom fields in RetailCRM';
|
||||||
$_['text_error_save'] = 'Error when saving settings';
|
$_['text_error_save'] = 'Error when saving settings';
|
||||||
$_['text_error_log'] = 'Log size is more than 2MB';
|
$_['text_error_log'] = 'Log size is more than 2MB';
|
||||||
$_['text_error_delivery'] = 'Delivery types are not found';
|
$_['text_error_delivery'] = 'Delivery types are not found';
|
||||||
|
@ -68,17 +71,28 @@ $_['retailcrm_dict_default'] = 'By default';
|
||||||
$_['retailcrm_missing_status'] = 'Status of lost orders';
|
$_['retailcrm_missing_status'] = 'Status of lost orders';
|
||||||
|
|
||||||
$_['order_number'] = 'Order number';
|
$_['order_number'] = 'Order number';
|
||||||
$_['text_order_number'] = 'Upload the order number to retailCRM';
|
$_['text_order_number'] = 'Upload the order number to RetailCRM';
|
||||||
$_['text_currency'] = 'Currency setting';
|
$_['summ_around'] = 'Around total summ';
|
||||||
$_['text_currency_label'] = 'Currency in ICML';
|
$_['text_summ_around'] = 'Around the order total summ';
|
||||||
|
$_['icml_settings'] = 'ICML settings';
|
||||||
|
$_['icml_service_enabled_label'] = 'Upload services in ICML';
|
||||||
|
$_['icml_service_description'] = 'When the option is enabled, all products for which delivery is disabled will be considered as services and uploaded to CRM as services';
|
||||||
|
$_['text_currency_label'] = 'Currency of goods';
|
||||||
$_['text_lenght'] = 'Setting of the unit of measurement';
|
$_['text_lenght'] = 'Setting of the unit of measurement';
|
||||||
$_['text_lenght_label'] = 'Unit of measurement in ICML';
|
$_['text_lenght_label'] = 'Unit of measurement of goods';
|
||||||
$_['status_changes'] = 'History of changes';
|
$_['status_changes'] = 'History of changes';
|
||||||
$_['text_status_changes'] = 'Record changes to the order history of Opencart';
|
$_['text_status_changes'] = 'Record changes to the order history of Opencart';
|
||||||
|
|
||||||
$_['column_total'] = 'Total';
|
$_['column_total'] = 'Total';
|
||||||
$_['product_summ'] = 'Sum';
|
$_['product_summ'] = 'Sum';
|
||||||
|
|
||||||
|
$_['text_retailcrm_discount'] = 'RetailCRM discount';
|
||||||
|
$_['text_retailcrm_label_discount'] = 'Label of RetailCRM discount in section total of order';
|
||||||
|
$_['default_retailcrm_label_discount'] = 'Discount in RetailCRM';
|
||||||
|
|
||||||
|
$_['sum_payment'] = 'Sum payment';
|
||||||
|
$_['text_sum_payment'] = 'Do not upload the sum payment to RetailCRM';
|
||||||
|
|
||||||
$_['article'] = 'Article';
|
$_['article'] = 'Article';
|
||||||
$_['color'] = 'Color';
|
$_['color'] = 'Color';
|
||||||
$_['weight'] = 'Weight';
|
$_['weight'] = 'Weight';
|
||||||
|
@ -86,5 +100,8 @@ $_['size'] = 'Size';
|
||||||
|
|
||||||
$_['text_yes'] = 'Yes';
|
$_['text_yes'] = 'Yes';
|
||||||
$_['text_no'] = 'No';
|
$_['text_no'] = 'No';
|
||||||
|
|
||||||
|
$_['entry_code'] = 'Online consultant code';
|
||||||
|
$_['entry_status'] = 'Use code for online consultant';
|
||||||
// Errors
|
// Errors
|
||||||
$_['error_permission'] = 'You do not have rights for changing the module settings';
|
$_['error_permission'] = 'You do not have rights for changing the module settings';
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Heading Goes here:
|
// Heading Goes here:
|
||||||
$_['heading_title'] = 'retailCRM';
|
$_['heading_title'] = 'RetailCRM';
|
||||||
$_['retailcrm_title'] = 'retailCRM';
|
$_['retailcrm_title'] = 'RetailCRM';
|
||||||
|
|
||||||
// Text
|
// Text
|
||||||
$_['text_module'] = 'Módulos';
|
$_['text_module'] = 'Módulos';
|
||||||
|
@ -13,15 +13,15 @@ $_['retailcrm_dict_settings'] = 'Ajustes de coincidencia de directorios';
|
||||||
$_['retailcrm_countries_settings'] = 'Configurar zonas comerciales';
|
$_['retailcrm_countries_settings'] = 'Configurar zonas comerciales';
|
||||||
$_['retailcrm_upload_order'] = 'Exportación de un pedido';
|
$_['retailcrm_upload_order'] = 'Exportación de un pedido';
|
||||||
$_['daemon_collector'] = 'Daemon Collector';
|
$_['daemon_collector'] = 'Daemon Collector';
|
||||||
|
$_['consultant_tab_text'] = 'Online Consultant';
|
||||||
$_['general_tab_text'] = 'Inicio';
|
$_['general_tab_text'] = 'Inicio';
|
||||||
$_['references_tab_text'] = 'Directorios';
|
$_['references_tab_text'] = 'Directorios';
|
||||||
$_['collector_tab_text'] = 'Daemon Collector';
|
$_['collector_tab_text'] = 'Daemon Collector';
|
||||||
$_['logs_tab_text'] = 'Registro';
|
$_['logs_tab_text'] = 'Registro';
|
||||||
$_['collector_custom_text'] = 'Configurar campos de formulario';
|
$_['collector_custom_text'] = 'Configurar campos de formulario';
|
||||||
$_['custom_fields_tab_text'] = 'Campos personalizados';
|
$_['custom_fields_tab_text'] = 'Campos personalizados';
|
||||||
$_['retailcrm_apiversion'] = 'Versión de la API';
|
$_['retailcrm_url'] = 'Dirección del RetailCRM';
|
||||||
$_['retailcrm_url'] = 'Dirección del retailCRM';
|
$_['retailcrm_apikey'] = 'Clave de la API del RetailCRM';
|
||||||
$_['retailcrm_apikey'] = 'Clave de la API del retailCRM';
|
|
||||||
$_['corporate_enabled_label'] = 'Corporate customers support';
|
$_['corporate_enabled_label'] = 'Corporate customers support';
|
||||||
$_['collector_site_key'] = 'Clave de la página web';
|
$_['collector_site_key'] = 'Clave de la página web';
|
||||||
$_['special_price_settings'] = 'Ajuste de la descarga del precio promocional';
|
$_['special_price_settings'] = 'Ajuste de la descarga del precio promocional';
|
||||||
|
@ -51,10 +51,13 @@ $_['text_shipping'] = 'Envío';
|
||||||
$_['text_orders_custom_fields'] = 'Los campos de pedidos personalizados';
|
$_['text_orders_custom_fields'] = 'Los campos de pedidos personalizados';
|
||||||
$_['text_customers_custom_fields'] = 'Los campos de clientes personalizados';
|
$_['text_customers_custom_fields'] = 'Los campos de clientes personalizados';
|
||||||
$_['text_error_collector_fields']= 'Rellene los nombres de los campos del formulario Daemon Collector';
|
$_['text_error_collector_fields']= 'Rellene los nombres de los campos del formulario Daemon Collector';
|
||||||
$_['text_error_api'] = 'La versión seleccionada de la API no está disponible.';
|
$_['text_error_api_empty'] = 'Los campos "URL de RetailCRM" y "Clave de API de RetailCRM" no pueden estar vacíos, ingrese el valor correcto';
|
||||||
$_['text_error_custom_field'] = 'Cree campos personalizados en la ficha del cliente en Opencart y retailCRM para configurar sus transmisión.';
|
$_['text_error_api_key'] = 'Clave API del CRM no válida';
|
||||||
|
$_['text_error_api_key_site'] = 'Se requiere clave API con acceso a una tienda';
|
||||||
|
$_['text_error_api_key_currency'] = 'La moneda del sitio web es distinto a la tienda del CRM. Para el funcionamiento correcto de la integración, las monedas del CMS y CRM deben coincid';
|
||||||
|
$_['text_error_custom_field'] = 'Cree campos personalizados en la ficha del cliente en Opencart y RetailCRM para configurar sus transmisión.';
|
||||||
$_['text_error_cf_opencart'] = 'Faltan campos personalizados en Opencart';
|
$_['text_error_cf_opencart'] = 'Faltan campos personalizados en Opencart';
|
||||||
$_['text_error_cf_retailcrm'] = 'Faltan campos personalizados en retailCRM';
|
$_['text_error_cf_retailcrm'] = 'Faltan campos personalizados en RetailCRM';
|
||||||
$_['text_error_save'] = 'Error al guardar la configuración';
|
$_['text_error_save'] = 'Error al guardar la configuración';
|
||||||
$_['text_error_log'] = 'El Tamaño del registro es más de 2MB';
|
$_['text_error_log'] = 'El Tamaño del registro es más de 2MB';
|
||||||
$_['text_error_delivery'] = 'No se encontraron los métodos de envío';
|
$_['text_error_delivery'] = 'No se encontraron los métodos de envío';
|
||||||
|
@ -68,17 +71,29 @@ $_['retailcrm_dict_default'] = 'Por defecto';
|
||||||
$_['retailcrm_missing_status'] = 'Estado de pedidos perdidos';
|
$_['retailcrm_missing_status'] = 'Estado de pedidos perdidos';
|
||||||
|
|
||||||
$_['order_number'] = 'Número de pedido';
|
$_['order_number'] = 'Número de pedido';
|
||||||
$_['text_order_number'] = 'Transferir número de pedido a retailCRM';
|
$_['text_order_number'] = 'Transferir número de pedido a RetailCRM';
|
||||||
$_['text_currency'] = 'Ajustes de moneda';
|
$_['summ_around'] = 'Redondeo del costo del pedido';
|
||||||
$_['text_currency_label'] = 'Moneda en ICML';
|
$_['text_summ_around'] = 'Redondear los costos del pedido a RetailCRM';
|
||||||
|
$_['icml_settings'] = 'Ajustes de ICML';
|
||||||
|
$_['icml_service_enabled_label'] = 'Subir servicios de ICML';
|
||||||
|
$_['icml_service_description'] = 'Si habilita la opción, todos los productos para los que la entrega está desactivada se tratarán como servicios y se cargarán en CRM como servicios';
|
||||||
|
|
||||||
|
$_['text_currency_label'] = 'Moneda de bienes';
|
||||||
$_['text_lenght'] = 'Ajustar unidad de medida';
|
$_['text_lenght'] = 'Ajustar unidad de medida';
|
||||||
$_['text_lenght_label'] = 'Unidad de medida en ICML';
|
$_['text_lenght_label'] = 'Unidad de medida de bienes';
|
||||||
$_['status_changes'] = 'Historial de cambios';
|
$_['status_changes'] = 'Historial de cambios';
|
||||||
$_['text_status_changes'] = 'Registrar los cambios en el historial de pedidos de Opencart';
|
$_['text_status_changes'] = 'Registrar los cambios en el historial de pedidos de Opencart';
|
||||||
|
|
||||||
$_['column_total'] = 'Total';
|
$_['column_total'] = 'Total';
|
||||||
$_['product_summ'] = 'Importe';
|
$_['product_summ'] = 'Importe';
|
||||||
|
|
||||||
|
$_['text_retailcrm_discount'] = 'RetailCRM descuento';
|
||||||
|
$_['text_retailcrm_label_discount'] = 'Etiqueta de descuento de RetailCRM en la sección total del pedido';
|
||||||
|
$_['default_retailcrm_label_discount'] = 'Descuento en RetailCRM';
|
||||||
|
|
||||||
|
$_['sum_payment'] = 'Suma de pago';
|
||||||
|
$_['text_sum_payment'] = 'No transferir suma de pago a RetailCRM';
|
||||||
|
|
||||||
$_['article'] = 'Artículo';
|
$_['article'] = 'Artículo';
|
||||||
$_['color'] = 'Color';
|
$_['color'] = 'Color';
|
||||||
$_['weight'] = 'Peso';
|
$_['weight'] = 'Peso';
|
||||||
|
@ -86,5 +101,8 @@ $_['size'] = 'Tamaño';
|
||||||
|
|
||||||
$_['text_yes'] = 'Sí';
|
$_['text_yes'] = 'Sí';
|
||||||
$_['text_no'] = 'No';
|
$_['text_no'] = 'No';
|
||||||
|
|
||||||
|
$_['entry_code'] = 'Código para online consultant';
|
||||||
|
$_['entry_status'] = 'Usar código para online consultant';
|
||||||
// Errors
|
// Errors
|
||||||
$_['error_permission'] = 'No tiene suficientes permisos para cambiar la configuración del módulo';
|
$_['error_permission'] = 'No tiene suficientes permisos para cambiar la configuración del módulo';
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Heading Goes here:
|
// Heading Goes here:
|
||||||
$_['heading_title'] = 'retailCRM';
|
$_['heading_title'] = 'RetailCRM';
|
||||||
$_['retailcrm_title'] = 'retailCRM';
|
$_['retailcrm_title'] = 'RetailCRM';
|
||||||
|
|
||||||
// Text
|
// Text
|
||||||
$_['text_module'] = 'Модули';
|
$_['text_module'] = 'Модули';
|
||||||
|
@ -16,10 +16,10 @@ $_['daemon_collector'] = 'Демон Collector';
|
||||||
$_['general_tab_text'] = 'Главная';
|
$_['general_tab_text'] = 'Главная';
|
||||||
$_['references_tab_text'] = 'Справочники';
|
$_['references_tab_text'] = 'Справочники';
|
||||||
$_['collector_tab_text'] = 'Daemon Collector';
|
$_['collector_tab_text'] = 'Daemon Collector';
|
||||||
|
$_['consultant_tab_text'] = 'Online Consultant';
|
||||||
$_['logs_tab_text'] = 'Логи';
|
$_['logs_tab_text'] = 'Логи';
|
||||||
$_['collector_custom_text'] = 'Настройка полей формы';
|
$_['collector_custom_text'] = 'Настройка полей формы';
|
||||||
$_['custom_fields_tab_text'] = 'Пользовательские поля';
|
$_['custom_fields_tab_text'] = 'Пользовательские поля';
|
||||||
$_['retailcrm_apiversion'] = 'Версия API';
|
|
||||||
$_['retailcrm_url'] = 'Адрес RetailCRM';
|
$_['retailcrm_url'] = 'Адрес RetailCRM';
|
||||||
$_['retailcrm_apikey'] = 'Api ключ RetailCRM';
|
$_['retailcrm_apikey'] = 'Api ключ RetailCRM';
|
||||||
$_['corporate_enabled_label'] = 'Поддержка корпоративных клиентов';
|
$_['corporate_enabled_label'] = 'Поддержка корпоративных клиентов';
|
||||||
|
@ -50,8 +50,11 @@ $_['text_payment'] = 'Оплата';
|
||||||
$_['text_shipping'] = 'Доставка';
|
$_['text_shipping'] = 'Доставка';
|
||||||
$_['text_orders_custom_fields'] = 'Кастомные поля заказов';
|
$_['text_orders_custom_fields'] = 'Кастомные поля заказов';
|
||||||
$_['text_customers_custom_fields'] = 'Кастомные поля клиентов';
|
$_['text_customers_custom_fields'] = 'Кастомные поля клиентов';
|
||||||
$_['text_error_collector_fields']= 'Заполните названия полей формы Демон Collector';
|
$_['text_error_collector_fields'] = 'Заполните названия полей формы Демон Collector';
|
||||||
$_['text_error_api'] = 'Недоступна выбранная версия API.';
|
$_['text_error_api_empty'] = 'Поля "URL RetailCRM" и "Ключ API RetailCRM" не могут быть пустыми, введите корректное значение';
|
||||||
|
$_['text_error_api_key'] = 'Неверный API ключ';
|
||||||
|
$_['text_error_api_key_site'] = 'Требуется API ключ с доступом к одному магазину';
|
||||||
|
$_['text_error_api_key_currency'] = 'Валюта сайта отличается от валюты магазина в CRM. Для корректной работы интеграции, валюты в CRM и CMS должны совпадать';
|
||||||
$_['text_error_custom_field'] = 'Создайте пользовательские поля в карточке клиента в Opencart и RetailCRM, чтобы настроить их передачу';
|
$_['text_error_custom_field'] = 'Создайте пользовательские поля в карточке клиента в Opencart и RetailCRM, чтобы настроить их передачу';
|
||||||
$_['text_error_cf_opencart'] = 'Отсутствуют пользовательские поля в Opencart';
|
$_['text_error_cf_opencart'] = 'Отсутствуют пользовательские поля в Opencart';
|
||||||
$_['text_error_cf_retailcrm'] = 'Отсутствуют пользовательские поля в RetailCRM';
|
$_['text_error_cf_retailcrm'] = 'Отсутствуют пользовательские поля в RetailCRM';
|
||||||
|
@ -68,17 +71,28 @@ $_['retailcrm_dict_default'] = 'По умолчанию';
|
||||||
$_['retailcrm_missing_status'] = 'Статус пропавших заказов';
|
$_['retailcrm_missing_status'] = 'Статус пропавших заказов';
|
||||||
|
|
||||||
$_['order_number'] = 'Номер заказа';
|
$_['order_number'] = 'Номер заказа';
|
||||||
$_['text_order_number'] = 'Передавать номер заказа в retailCRM';
|
$_['text_order_number'] = 'Передавать номер заказа в RetailCRM';
|
||||||
$_['text_currency'] = 'Настройка валюты';
|
$_['summ_around'] = 'Округление суммы заказа';
|
||||||
$_['text_currency_label'] = 'Валюта в ICML';
|
$_['text_summ_around'] = 'Округлять сумму заказа';
|
||||||
|
$_['icml_settings'] = 'Настройки ICML';
|
||||||
|
$_['icml_service_enabled_label'] = 'Выгружать услуги в ICML';
|
||||||
|
$_['icml_service_description'] = 'При включении опции все товары, для которых отключена доставка, будут рассматриваться как услуги и загружаться в CRM как услуги';
|
||||||
|
$_['text_currency_label'] = 'Валюта товаров';
|
||||||
$_['text_lenght'] = 'Настройка единицы измерения';
|
$_['text_lenght'] = 'Настройка единицы измерения';
|
||||||
$_['text_lenght_label'] = 'Единица измерения в ICML';
|
$_['text_lenght_label'] = 'Единица измерения товаров';
|
||||||
$_['status_changes'] = 'История изменений';
|
$_['status_changes'] = 'История изменений';
|
||||||
$_['text_status_changes'] = 'Фиксировать изменения в истории заказа Opencart';
|
$_['text_status_changes'] = 'Фиксировать изменения в истории заказа Opencart';
|
||||||
|
|
||||||
$_['column_total'] = 'Итого';
|
$_['column_total'] = 'Итого';
|
||||||
$_['product_summ'] = 'Сумма';
|
$_['product_summ'] = 'Сумма';
|
||||||
|
|
||||||
|
$_['text_retailcrm_discount'] = 'Скидка RetailCRM';
|
||||||
|
$_['text_retailcrm_label_discount'] = 'Подпись для скидки, установленной в RetailCRM, в итоговой секции заказа';
|
||||||
|
$_['default_retailcrm_label_discount'] = 'Скидка в RetailCRM';
|
||||||
|
|
||||||
|
$_['sum_payment'] = 'Сумма платежа';
|
||||||
|
$_['text_sum_payment'] = 'Не передавать сумму платежа в RetailCRM';
|
||||||
|
|
||||||
$_['article'] = 'Артикул';
|
$_['article'] = 'Артикул';
|
||||||
$_['color'] = 'Цвет';
|
$_['color'] = 'Цвет';
|
||||||
$_['weight'] = 'Вес';
|
$_['weight'] = 'Вес';
|
||||||
|
@ -88,3 +102,8 @@ $_['text_yes'] = 'Да';
|
||||||
$_['text_no'] = 'Нет';
|
$_['text_no'] = 'Нет';
|
||||||
// Errors
|
// Errors
|
||||||
$_['error_permission'] = 'У вас недостаточно прав на изменение настроек модуля';
|
$_['error_permission'] = 'У вас недостаточно прав на изменение настроек модуля';
|
||||||
|
|
||||||
|
//online consultant
|
||||||
|
$_['entry_code'] = 'Код для online consultant';
|
||||||
|
$_['entry_status'] = 'Использовать код для online consultant';
|
||||||
|
|
||||||
|
|
|
@ -72,15 +72,10 @@ class ModelExtensionRetailcrmHistory extends Model {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sinceIdOrders = $history['retailcrm_history_orders'] ? $history['retailcrm_history_orders'] : null;
|
$sinceIdOrders = $history['retailcrm_history_orders'] ?? 0;
|
||||||
$sinceIdCustomers = $history['retailcrm_history_customers'] ? $history['retailcrm_history_customers'] : null;
|
$sinceIdCustomers = $history['retailcrm_history_customers'] ?? 0;
|
||||||
|
$packsOrders = $retailcrmApiClient->ordersHistory(['sinceId' => $sinceIdOrders]);
|
||||||
$packsOrders = $retailcrmApiClient->ordersHistory(array(
|
$packsCustomers = $retailcrmApiClient->customersHistory(['sinceId' => $sinceIdCustomers]);
|
||||||
'sinceId' => $sinceIdOrders ? $sinceIdOrders : 0
|
|
||||||
), 1, 100);
|
|
||||||
$packsCustomers = $retailcrmApiClient->customersHistory(array(
|
|
||||||
'sinceId' => $sinceIdCustomers ? $sinceIdCustomers : 0
|
|
||||||
), 1, 100);
|
|
||||||
|
|
||||||
if (!$packsOrders->isSuccessful() && count($packsOrders->history) <= 0
|
if (!$packsOrders->isSuccessful() && count($packsOrders->history) <= 0
|
||||||
&& !$packsCustomers->isSuccessful() && count($packsCustomers->history) <= 0
|
&& !$packsCustomers->isSuccessful() && count($packsCustomers->history) <= 0
|
||||||
|
@ -88,30 +83,28 @@ class ModelExtensionRetailcrmHistory extends Model {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$orders = RetailcrmHistoryHelper::assemblyOrder($packsOrders->history);
|
|
||||||
$customers = RetailcrmHistoryHelper::assemblyCustomer($packsCustomers->history);
|
|
||||||
|
|
||||||
$ordersHistory = $packsOrders->history;
|
$ordersHistory = $packsOrders->history;
|
||||||
$customersHistory = $packsCustomers->history;
|
$customersHistory = $packsCustomers->history;
|
||||||
|
|
||||||
$lastChangeOrders = $ordersHistory ? end($ordersHistory) : null;
|
$lastChangeOrders = $ordersHistory ? end($ordersHistory) : null;
|
||||||
$lastChangeCustomers = $customersHistory ? end($customersHistory) : null;
|
$lastChangeCustomers = $customersHistory ? end($customersHistory) : null;
|
||||||
|
|
||||||
if ($lastChangeOrders !== null) {
|
if ($lastChangeOrders !== null && $lastChangeCustomers !== null) {
|
||||||
$sinceIdOrders = $lastChangeOrders['id'];
|
$this->model_setting_setting->editSetting(
|
||||||
}
|
'retailcrm_history',
|
||||||
|
[
|
||||||
if ($lastChangeCustomers !== null) {
|
'retailcrm_history_orders' => $lastChangeOrders['id'],
|
||||||
$sinceIdCustomers = $lastChangeCustomers['id'];
|
'retailcrm_history_customers' => $lastChangeCustomers['id']
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$orders = RetailcrmHistoryHelper::assemblyOrder($ordersHistory);
|
||||||
|
$customers = RetailcrmHistoryHelper::assemblyCustomer($customersHistory);
|
||||||
|
$newOrders = [];
|
||||||
|
$updatedOrders = [];
|
||||||
$this->settings = $settings;
|
$this->settings = $settings;
|
||||||
|
|
||||||
$this->status = array_flip($settings[$this->moduleTitle . '_status']);
|
$this->status = array_flip($settings[$this->moduleTitle . '_status']);
|
||||||
|
|
||||||
$updatedOrders = array();
|
|
||||||
$newOrders = array();
|
|
||||||
|
|
||||||
foreach ($orders as $order) {
|
foreach ($orders as $order) {
|
||||||
if (isset($order['deleted'])) {
|
if (isset($order['deleted'])) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -126,7 +119,7 @@ class ModelExtensionRetailcrmHistory extends Model {
|
||||||
|
|
||||||
unset($orders);
|
unset($orders);
|
||||||
|
|
||||||
$updateCustomers = array();
|
$updateCustomers = [];
|
||||||
|
|
||||||
foreach ($customers as $customer) {
|
foreach ($customers as $customer) {
|
||||||
if (isset($customer['deleted'])) {
|
if (isset($customer['deleted'])) {
|
||||||
|
@ -141,34 +134,27 @@ class ModelExtensionRetailcrmHistory extends Model {
|
||||||
unset($customers);
|
unset($customers);
|
||||||
|
|
||||||
if (!empty($updateCustomers)) {
|
if (!empty($updateCustomers)) {
|
||||||
$customers = $retailcrmApiClient->customersList(array('ids' => $updateCustomers));
|
$customers = $retailcrmApiClient->customersList(['ids' => $updateCustomers]);
|
||||||
if ($customers) {
|
if ($customers) {
|
||||||
$this->updateCustomers($customers['customers']);
|
$this->updateCustomers($customers['customers']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($newOrders)) {
|
if (!empty($newOrders)) {
|
||||||
$orders = $retailcrmApiClient->ordersList(array('ids' => $newOrders));
|
$orders = $retailcrmApiClient->ordersList(['ids' => $newOrders]);
|
||||||
if ($orders) {
|
if ($orders) {
|
||||||
$this->createResult = $this->createOrders($orders['orders'], $retailcrmApiClient);
|
$this->createResult = $this->createOrders($orders['orders'], $retailcrmApiClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($updatedOrders)) {
|
if (!empty($updatedOrders)) {
|
||||||
$orders = $retailcrmApiClient->ordersList(array('ids' => $updatedOrders));
|
$orders = $retailcrmApiClient->ordersList(['ids' => $updatedOrders]);
|
||||||
|
|
||||||
if ($orders) {
|
if ($orders) {
|
||||||
$this->updateOrders($orders['orders'], $retailcrmApiClient);
|
$this->updateOrders($orders['orders'], $retailcrmApiClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->model_setting_setting->editSetting(
|
|
||||||
'retailcrm_history',
|
|
||||||
array(
|
|
||||||
'retailcrm_history_orders' => $sinceIdOrders,
|
|
||||||
'retailcrm_history_customers' => $sinceIdCustomers
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!empty($this->createResult['customers'])) {
|
if (!empty($this->createResult['customers'])) {
|
||||||
$retailcrmApiClient->customersFixExternalIds($this->createResult['customers']);
|
$retailcrmApiClient->customersFixExternalIds($this->createResult['customers']);
|
||||||
}
|
}
|
||||||
|
@ -315,10 +301,17 @@ class ModelExtensionRetailcrmHistory extends Model {
|
||||||
$this->customers_history->handleCustomer($customer_data, $customer);
|
$this->customers_history->handleCustomer($customer_data, $customer);
|
||||||
$this->customers_history->handleCustomFields($customer_data, $customer);
|
$this->customers_history->handleCustomFields($customer_data, $customer);
|
||||||
|
|
||||||
$updateAddress = $this->customers_history->handleAddress($customer, array(), $customer_data['address_id']);
|
if (empty($customer_data['address_id'])) {
|
||||||
$addresses = $this->model_customer_customer->getAddresses($customer_id);
|
$address = $this->customers_history->handleAddress($customer, array());
|
||||||
$addresses[$customer_data['address_id']] = $updateAddress;
|
$addresses = $this->model_customer_customer->getAddresses($customer_id);
|
||||||
$customer_data['address'] = $addresses;
|
$addresses[] = $address;
|
||||||
|
$customer_data['address'] = $addresses;
|
||||||
|
} else {
|
||||||
|
$updateAddress = $this->customers_history->handleAddress($customer, array(), $customer_data['address_id']);
|
||||||
|
$addresses = $this->model_customer_customer->getAddresses($customer_id);
|
||||||
|
$addresses[$customer_data['address_id']] = $updateAddress;
|
||||||
|
$customer_data['address'] = $addresses;
|
||||||
|
}
|
||||||
|
|
||||||
$this->model_customer_customer->editCustomer($customer_id, $customer_data);
|
$this->model_customer_customer->editCustomer($customer_id, $customer_data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,14 @@ class ModelExtensionRetailcrmIcml extends Model
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param Registry $registry
|
* @param Registry $registry
|
||||||
*/
|
*/
|
||||||
public function __construct($registry)
|
public function __construct($registry)
|
||||||
{
|
{
|
||||||
parent::__construct($registry);
|
parent::__construct($registry);
|
||||||
$this->load->library('retailcrm/retailcrm');
|
$this->load->library('retailcrm/retailcrm');
|
||||||
|
$this->load->model('localisation/weight_class');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateICML()
|
public function generateICML()
|
||||||
|
@ -77,7 +78,7 @@ class ModelExtensionRetailcrmIcml extends Model
|
||||||
*/
|
*/
|
||||||
private function addCategories()
|
private function addCategories()
|
||||||
{
|
{
|
||||||
$categories = $this->model_catalog_category->getCategories(array());
|
$categories = $this->model_catalog_category->getCategories([]);
|
||||||
foreach ($categories as $category) {
|
foreach ($categories as $category) {
|
||||||
$category = $this->model_catalog_category->getCategory($category['category_id']);
|
$category = $this->model_catalog_category->getCategory($category['category_id']);
|
||||||
|
|
||||||
|
@ -102,11 +103,18 @@ class ModelExtensionRetailcrmIcml extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addOffers() {
|
private function addOffers() {
|
||||||
$offerManufacturers = array();
|
$offerManufacturers = [];
|
||||||
|
$servicesForIcml = $this->retailcrm->useServicesForIcml();
|
||||||
$currencyForIcml = $this->retailcrm->getCurrencyForIcml();
|
$currencyForIcml = $this->retailcrm->getCurrencyForIcml();
|
||||||
$defaultCurrency = $this->getDefaultCurrency();
|
$defaultCurrency = $this->getDefaultCurrency();
|
||||||
$settingLenght = $this->retailcrm->getLenghtForIcml();
|
$settingLenght = $this->retailcrm->getLenghtForIcml();
|
||||||
$leghtsArray = $this->model_localisation_length_class->getLengthClasses();
|
$leghtsArray = $this->model_localisation_length_class->getLengthClasses();
|
||||||
|
$weightClassesMas = $this->model_localisation_weight_class->getWeightClasses();
|
||||||
|
$weightClasses = [];
|
||||||
|
|
||||||
|
foreach ($weightClassesMas as $weightClass) {
|
||||||
|
$weightClasses[$weightClass['weight_class_id']]['value'] = $weightClass['value'];
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($leghtsArray as $lenght) {
|
foreach ($leghtsArray as $lenght) {
|
||||||
if ($lenght['value'] == 1) {
|
if ($lenght['value'] == 1) {
|
||||||
|
@ -115,20 +123,20 @@ class ModelExtensionRetailcrmIcml extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
$manufacturers = $this->model_catalog_manufacturer
|
$manufacturers = $this->model_catalog_manufacturer
|
||||||
->getManufacturers(array());
|
->getManufacturers([]);
|
||||||
|
|
||||||
foreach ($manufacturers as $manufacturer) {
|
foreach ($manufacturers as $manufacturer) {
|
||||||
$offerManufacturers[$manufacturer['manufacturer_id']] = $manufacturer['name'];
|
$offerManufacturers[$manufacturer['manufacturer_id']] = $manufacturer['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$products = $this->model_catalog_product->getProducts(array());
|
$products = $this->model_catalog_product->getProducts([]);
|
||||||
|
|
||||||
foreach ($products as $product) {
|
foreach ($products as $product) {
|
||||||
$offers = $this->retailcrm->getOffers($product);
|
$offers = $this->retailcrm->getOffers($product);
|
||||||
|
|
||||||
foreach ($offers as $optionsString => $optionsValues) {
|
foreach ($offers as $optionsString => $optionsValues) {
|
||||||
$optionsString = explode('_', $optionsString);
|
$optionsString = explode('_', $optionsString);
|
||||||
$options = array();
|
$options = [];
|
||||||
|
|
||||||
foreach($optionsString as $optionString) {
|
foreach($optionsString as $optionString) {
|
||||||
$option = explode('-', $optionString);
|
$option = explode('-', $optionString);
|
||||||
|
@ -140,37 +148,46 @@ class ModelExtensionRetailcrmIcml extends Model
|
||||||
$options[$optionIds[0]] = array(
|
$options[$optionIds[0]] = array(
|
||||||
'name' => $optionData['optionName'],
|
'name' => $optionData['optionName'],
|
||||||
'value' => $optionData['optionValue'],
|
'value' => $optionData['optionValue'],
|
||||||
'value_id' => $option[1]
|
'value_id' => $option[1],
|
||||||
|
'option_id' => $optionIds[1]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ksort($options);
|
ksort($options);
|
||||||
|
|
||||||
$offerId = array();
|
$offerId = [];
|
||||||
|
|
||||||
foreach($options as $optionKey => $optionData) {
|
foreach($options as $optionKey => $optionData) {
|
||||||
$offerId[] = $optionKey.'-'.$optionData['value_id'];
|
$offerId[] = $optionKey.'-'.$optionData['value_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$offerId = implode('_', $offerId);
|
$offerId = implode('_', $offerId);
|
||||||
$e = $this->eOffers->appendChild($this->dd->createElement('offer'));
|
$catalog = $this->eOffers->appendChild($this->dd->createElement('offer'));
|
||||||
|
|
||||||
if (!empty($offerId)) {
|
if (!empty($offerId)) {
|
||||||
$e->setAttribute('id', $product['product_id'] . '#' . $offerId);
|
$catalog->setAttribute('id', $product['product_id'] . '#' . $offerId);
|
||||||
$e->setAttribute('productId', $product['product_id']);
|
$catalog->setAttribute('productId', $product['product_id']);
|
||||||
$e->setAttribute('quantity', $optionsValues['qty']);
|
$catalog->setAttribute('quantity', $optionsValues['qty']);
|
||||||
} else {
|
} else {
|
||||||
$e->setAttribute('id', $product['product_id']);
|
$catalog->setAttribute('id', $product['product_id']);
|
||||||
$e->setAttribute('productId', $product['product_id']);
|
$catalog->setAttribute('productId', $product['product_id']);
|
||||||
$e->setAttribute('quantity', $product['quantity']);
|
$catalog->setAttribute('quantity', $product['quantity']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set type for offers
|
||||||
|
*/
|
||||||
|
$useServices = $servicesForIcml && isset($product['shipping']) && $product['shipping'] == 0;
|
||||||
|
|
||||||
|
$catalog->setAttribute('type', $useServices ? 'service' : 'product');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offer activity
|
* Offer activity
|
||||||
*/
|
*/
|
||||||
$activity = $product['status'] == 1 ? 'Y' : 'N';
|
$activity = $product['status'] == 1 ? 'Y' : 'N';
|
||||||
$e->appendChild(
|
$catalog->appendChild(
|
||||||
$this->dd->createElement('productActivity')
|
$this->dd->createElement('productActivity')
|
||||||
)->appendChild(
|
)->appendChild(
|
||||||
$this->dd->createTextNode($activity)
|
$this->dd->createTextNode($activity)
|
||||||
|
@ -182,7 +199,7 @@ class ModelExtensionRetailcrmIcml extends Model
|
||||||
->getProductCategories($product['product_id']);
|
->getProductCategories($product['product_id']);
|
||||||
if (!empty($categories)) {
|
if (!empty($categories)) {
|
||||||
foreach ($categories as $category) {
|
foreach ($categories as $category) {
|
||||||
$e->appendChild($this->dd->createElement('categoryId'))
|
$catalog->appendChild($this->dd->createElement('categoryId'))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
$this->dd->createTextNode($category)
|
$this->dd->createTextNode($category)
|
||||||
);
|
);
|
||||||
|
@ -191,18 +208,18 @@ class ModelExtensionRetailcrmIcml extends Model
|
||||||
/**
|
/**
|
||||||
* Name & price
|
* Name & price
|
||||||
*/
|
*/
|
||||||
$e->appendChild($this->dd->createElement('productName'))
|
$catalog->appendChild($this->dd->createElement('productName'))
|
||||||
->appendChild($this->dd->createTextNode($product['name']));
|
->appendChild($this->dd->createTextNode($product['name']));
|
||||||
if (!empty($options)) {
|
if (!empty($options)) {
|
||||||
$optionsString = array();
|
$optionsString = [];
|
||||||
foreach($options as $option) {
|
foreach($options as $option) {
|
||||||
$optionsString[] = $option['name'].': '.$option['value'];
|
$optionsString[] = $option['name'].': '.$option['value'];
|
||||||
}
|
}
|
||||||
$optionsString = ' ('.implode(', ', $optionsString).')';
|
$optionsString = ' ('.implode(', ', $optionsString).')';
|
||||||
$e->appendChild($this->dd->createElement('name'))
|
$catalog->appendChild($this->dd->createElement('name'))
|
||||||
->appendChild($this->dd->createTextNode($product['name'].$optionsString));
|
->appendChild($this->dd->createTextNode($product['name'].$optionsString));
|
||||||
} else {
|
} else {
|
||||||
$e->appendChild($this->dd->createElement('name'))
|
$catalog->appendChild($this->dd->createElement('name'))
|
||||||
->appendChild($this->dd->createTextNode($product['name']));
|
->appendChild($this->dd->createTextNode($product['name']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,13 +233,13 @@ class ModelExtensionRetailcrmIcml extends Model
|
||||||
$price = $product['price'] + $optionsValues['price'];
|
$price = $product['price'] + $optionsValues['price'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$e->appendChild($this->dd->createElement('price'))
|
$catalog->appendChild($this->dd->createElement('price'))
|
||||||
->appendChild($this->dd->createTextNode($price));
|
->appendChild($this->dd->createTextNode($price));
|
||||||
/**
|
/**
|
||||||
* Vendor
|
* Vendor
|
||||||
*/
|
*/
|
||||||
if ($product['manufacturer_id'] != 0) {
|
if ($product['manufacturer_id'] != 0) {
|
||||||
$e->appendChild($this->dd->createElement('vendor'))
|
$catalog->appendChild($this->dd->createElement('vendor'))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
$this->dd->createTextNode(
|
$this->dd->createTextNode(
|
||||||
$offerManufacturers[$product['manufacturer_id']]
|
$offerManufacturers[$product['manufacturer_id']]
|
||||||
|
@ -234,7 +251,7 @@ class ModelExtensionRetailcrmIcml extends Model
|
||||||
* Dimensions
|
* Dimensions
|
||||||
*/
|
*/
|
||||||
if ((!empty($product['length']) && $product['length'] > 0) &&
|
if ((!empty($product['length']) && $product['length'] > 0) &&
|
||||||
(!empty($product['width'] && $product['width'] > 0))
|
(!empty($product['width']) && $product['width'] > 0)
|
||||||
&& !empty($product['height']))
|
&& !empty($product['height']))
|
||||||
{
|
{
|
||||||
$lenghtArray = $this->model_localisation_length_class->getLengthClass($product['length_class_id']);
|
$lenghtArray = $this->model_localisation_length_class->getLengthClass($product['length_class_id']);
|
||||||
|
@ -263,7 +280,7 @@ class ModelExtensionRetailcrmIcml extends Model
|
||||||
$productHeight
|
$productHeight
|
||||||
);
|
);
|
||||||
|
|
||||||
$e->appendChild($this->dd->createElement('dimensions'))
|
$catalog->appendChild($this->dd->createElement('dimensions'))
|
||||||
->appendChild($this->dd->createTextNode($dimensions));
|
->appendChild($this->dd->createTextNode($dimensions));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,34 +289,32 @@ class ModelExtensionRetailcrmIcml extends Model
|
||||||
*/
|
*/
|
||||||
if ($product['image']) {
|
if ($product['image']) {
|
||||||
$image = $this->generateImage($product['image']);
|
$image = $this->generateImage($product['image']);
|
||||||
$e->appendChild($this->dd->createElement('picture'))
|
$catalog->appendChild($this->dd->createElement('picture'))
|
||||||
->appendChild($this->dd->createTextNode($image));
|
->appendChild($this->dd->createTextNode($image));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Url
|
* Url
|
||||||
*/
|
*/
|
||||||
$this->url = new Url(
|
$this->url = new Url(HTTP_CATALOG, HTTPS_CATALOG);
|
||||||
HTTP_CATALOG,
|
$catalog->appendChild($this->dd->createElement('url'))
|
||||||
$this->config->get('config_secure')
|
|
||||||
? HTTP_CATALOG
|
|
||||||
: HTTPS_CATALOG
|
|
||||||
);
|
|
||||||
$e->appendChild($this->dd->createElement('url'))
|
|
||||||
->appendChild(
|
->appendChild(
|
||||||
$this->dd->createTextNode(
|
$this->dd->createTextNode(
|
||||||
$this->url->link(
|
$this->url->link(
|
||||||
'product/product&product_id=' . $product['product_id']
|
'product/product&product_id=' . $product['product_id'],
|
||||||
|
'',
|
||||||
|
(bool) $this->config->get('config_secure')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
if (!empty($options)) {
|
if (!empty($options)) {
|
||||||
foreach($options as $optionKey => $optionData) {
|
foreach($options as $optionKey => $optionData) {
|
||||||
$param = $this->dd->createElement('param');
|
$param = $this->dd->createElement('param');
|
||||||
$param->setAttribute('code', $optionKey);
|
$param->setAttribute('code', $optionData['option_id']);
|
||||||
$param->setAttribute('name', $optionData['name']);
|
$param->setAttribute('name', $optionData['name']);
|
||||||
$param->appendChild($this->dd->createTextNode($optionData['value']));
|
$param->appendChild($this->dd->createTextNode($optionData['value']));
|
||||||
$e->appendChild($param);
|
$catalog->appendChild($param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($product['sku']) {
|
if ($product['sku']) {
|
||||||
|
@ -307,18 +322,24 @@ class ModelExtensionRetailcrmIcml extends Model
|
||||||
$sku->setAttribute('code', 'article');
|
$sku->setAttribute('code', 'article');
|
||||||
$sku->setAttribute('name', $this->language->get('article'));
|
$sku->setAttribute('name', $this->language->get('article'));
|
||||||
$sku->appendChild($this->dd->createTextNode($product['sku']));
|
$sku->appendChild($this->dd->createTextNode($product['sku']));
|
||||||
$e->appendChild($sku);
|
$catalog->appendChild($sku);
|
||||||
}
|
}
|
||||||
if ($product['weight'] != '') {
|
if ($product['weight'] != '') {
|
||||||
$weight = $this->dd->createElement('param');
|
$weight = $this->dd->createElement('weight');
|
||||||
$weight->setAttribute('code', 'weight');
|
$coeffWeight = 1;
|
||||||
$weight->setAttribute('name', $this->language->get('weight'));
|
|
||||||
$weightValue = (isset($product['weight_class']))
|
if (!empty($weightClasses[$product['weight_class_id']]['value'])) {
|
||||||
? round($product['weight'], 3) . ' ' . $product['weight_class']
|
$coeffWeight = $weightClasses[$product['weight_class_id']]['value'];
|
||||||
: round($product['weight'], 3)
|
}
|
||||||
|
|
||||||
|
$weightValue = !empty($optionsValues['weight'])
|
||||||
|
? $product['weight'] + $optionsValues['weight']
|
||||||
|
: $product['weight']
|
||||||
;
|
;
|
||||||
|
$weightValue = round($weightValue / $coeffWeight, 6);
|
||||||
|
|
||||||
$weight->appendChild($this->dd->createTextNode($weightValue));
|
$weight->appendChild($this->dd->createTextNode($weightValue));
|
||||||
$e->appendChild($weight);
|
$catalog->appendChild($weight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,7 +352,7 @@ class ModelExtensionRetailcrmIcml extends Model
|
||||||
private function generateImage($image)
|
private function generateImage($image)
|
||||||
{
|
{
|
||||||
$this->load->model('tool/image');
|
$this->load->model('tool/image');
|
||||||
|
|
||||||
$currentTheme = $this->config->get('config_theme');
|
$currentTheme = $this->config->get('config_theme');
|
||||||
$width = $this->config->get($currentTheme . '_image_related_width') ? $this->config->get($currentTheme . '_image_related_width') : 200;
|
$width = $this->config->get($currentTheme . '_image_related_width') ? $this->config->get($currentTheme . '_image_related_width') : 200;
|
||||||
$height = $this->config->get($currentTheme . '_image_related_height') ? $this->config->get($currentTheme . '_image_related_height') : 200;
|
$height = $this->config->get($currentTheme . '_image_related_height') ? $this->config->get($currentTheme . '_image_related_height') : 200;
|
||||||
|
|
|
@ -60,10 +60,6 @@ class ModelExtensionRetailcrmPrices extends Model
|
||||||
$prices = array();
|
$prices = array();
|
||||||
$site = $this->getSite($retailcrmApiClient);
|
$site = $this->getSite($retailcrmApiClient);
|
||||||
|
|
||||||
if ($this->settings[$this->moduleTitle . '_apiversion'] == 'v3') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($products as $product) {
|
foreach ($products as $product) {
|
||||||
$specials = $this->model_catalog_product->getProductSpecials($product['product_id']);
|
$specials = $this->model_catalog_product->getProductSpecials($product['product_id']);
|
||||||
|
|
||||||
|
@ -175,13 +171,13 @@ class ModelExtensionRetailcrmPrices extends Model
|
||||||
) {
|
) {
|
||||||
$productPrice[$special['customer_group_id']]['price'] = $special['price'];
|
$productPrice[$special['customer_group_id']]['price'] = $special['price'];
|
||||||
$productPrice[$special['customer_group_id']]['remove'] = false;
|
$productPrice[$special['customer_group_id']]['remove'] = false;
|
||||||
$priority = $special['priority'];
|
|
||||||
$groupId = $special['customer_group_id'];
|
$groupId = $special['customer_group_id'];
|
||||||
|
$priority = $special['priority'];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$productPrice[$special['customer_group_id']]['price'] = $special['price'];
|
$productPrice[$special['customer_group_id']]['price'] = $special['price'];
|
||||||
$groupId = $special['customer_group_id'];
|
|
||||||
$productPrice[$special['customer_group_id']]['remove'] = false;
|
$productPrice[$special['customer_group_id']]['remove'] = false;
|
||||||
|
$groupId = $special['customer_group_id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,6 +158,22 @@ class ModelExtensionRetailcrmReferences extends Model
|
||||||
return (!$response->isSuccessful()) ? array() : $response->deliveryTypes;
|
return (!$response->isSuccessful()) ? array() : $response->deliveryTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get RetailCRM available sites list
|
||||||
|
*/
|
||||||
|
public function getApiSite()
|
||||||
|
{
|
||||||
|
$response = $this->retailcrmApiClient->sitesList();
|
||||||
|
|
||||||
|
if (!$response || !$response->isSuccessful()) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sites = $response->sites;
|
||||||
|
|
||||||
|
return end($sites);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get RetailCRM order statuses
|
* Get RetailCRM order statuses
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
.retailcrm_unit {margin-bottom: 10px;}
|
.retailcrm_unit {margin-bottom: 10px;}
|
||||||
|
.retailcrm_disable_border {border: none !important;}
|
||||||
.retailcrm_unit input {width: 30%;}
|
.retailcrm_unit input {width: 30%;}
|
||||||
.checkbox input{width: auto;}
|
.checkbox input{width: auto;}
|
||||||
.retailcrm_unit input[type=checkbox] {width: 13px;}
|
.retailcrm_unit input[type=checkbox] {width: 13px;}
|
||||||
.retailcrm_unit select {max-width: 500px;}
|
.retailcrm_unit select {max-width: 500px;}
|
||||||
|
|
||||||
|
.question-mark {
|
||||||
|
cursor: help;
|
||||||
|
position: relative;
|
||||||
|
}
|
|
@ -40,6 +40,7 @@
|
||||||
<?php if (isset($saved_settings['retailcrm_apikey']) && $saved_settings['retailcrm_apikey'] != '' && isset($saved_settings['retailcrm_url']) && $saved_settings['retailcrm_url'] != ''): ?>
|
<?php if (isset($saved_settings['retailcrm_apikey']) && $saved_settings['retailcrm_apikey'] != '' && isset($saved_settings['retailcrm_url']) && $saved_settings['retailcrm_url'] != ''): ?>
|
||||||
<li><a href="#tab-references" data-toggle="tab"><?php echo $references_tab_text; ?></a></li>
|
<li><a href="#tab-references" data-toggle="tab"><?php echo $references_tab_text; ?></a></li>
|
||||||
<li><a href="#tab-collector" data-toggle="tab"><?php echo $collector_tab_text; ?></a></li>
|
<li><a href="#tab-collector" data-toggle="tab"><?php echo $collector_tab_text; ?></a></li>
|
||||||
|
<li><a href="#tab-consultant" data-toggle="tab"><?php echo $consultant_tab_text; ?></a></li>
|
||||||
<li><a href="#tab-custom_fields" data-toggle="tab"><?php echo $custom_fields_tab_text; ?></a></li>
|
<li><a href="#tab-custom_fields" data-toggle="tab"><?php echo $custom_fields_tab_text; ?></a></li>
|
||||||
<li><a href="#tab-logs" data-toggle="tab"><?php echo $logs_tab_text; ?></a></li>
|
<li><a href="#tab-logs" data-toggle="tab"><?php echo $logs_tab_text; ?></a></li>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
@ -96,7 +97,22 @@
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><?php echo $text_currency; ?></legend>
|
<legend><?php echo $icml_settings; ?></legend>
|
||||||
|
<div class="form-group retailcrm_unit">
|
||||||
|
<label class="col-sm-2 control-label question-mark" for="retailcrm_icml_service_enabled" title="When the option is enabled, all products for which delivery is disabled will be considered as services and uploaded to CRM as services"><?php echo $icml_service_enabled_label; ?></label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<label class="radio-inline">
|
||||||
|
<input type="radio" name="retailcrm_icml_service_enabled value="1"
|
||||||
|
<?php if(isset($saved_settings['retailcrm_icml_service_enabled']) && $saved_settings['retailcrm_icml_service_enabled'] == 1): echo 'checked'; endif;?>/>
|
||||||
|
<?php echo $text_yes; ?>
|
||||||
|
</label>
|
||||||
|
<label class="radio-inline">
|
||||||
|
<input type="radio" name="retailcrm_icml_service_enabled" value="0"
|
||||||
|
<?php if(!isset($saved_settings['retailcrm_icml_service_enabled']) || $saved_settings['retailcrm_icml_service_enabled'] == 0): echo 'checked'; endif;?>/>
|
||||||
|
<?php echo $text_no; ?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div
|
||||||
<div class="form-group retailcrm_unit">
|
<div class="form-group retailcrm_unit">
|
||||||
<label class="col-sm-2 control-label"><?php echo $text_currency; ?></label>
|
<label class="col-sm-2 control-label"><?php echo $text_currency; ?></label>
|
||||||
<div class="col-md-4 col-sm-10">
|
<div class="col-md-4 col-sm-10">
|
||||||
|
@ -111,9 +127,6 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
|
||||||
<fieldset>
|
|
||||||
<legend><?php echo $text_lenght; ?></legend>
|
|
||||||
<div class="form-group retailcrm_unit">
|
<div class="form-group retailcrm_unit">
|
||||||
<label class="col-sm-2 control-label"><?php echo $text_lenght_label; ?></label>
|
<label class="col-sm-2 control-label"><?php echo $text_lenght_label; ?></label>
|
||||||
<div class="col-md-4 col-sm-10">
|
<div class="col-md-4 col-sm-10">
|
||||||
|
@ -212,6 +225,55 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<legend><?php echo $summ_around; ?></legend>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-2 control-label" for="retailcrm_summ_around"><?php echo $text_summ_around; ?></label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<label class="radio-inline">
|
||||||
|
<input type="radio" name="retailcrm_summ_around" value="1" <?php if (isset($saved_settings['retailcrm_summ_around']) &&
|
||||||
|
$saved_settings['retailcrm_summ_around'] == 1) :
|
||||||
|
echo 'checked'; endif; ?> />
|
||||||
|
<?php echo $text_yes; ?>
|
||||||
|
</label>
|
||||||
|
<label class="radio-inline">
|
||||||
|
<input type="radio" name="retailcrm_summ_around" value="0" <?php if (!isset($saved_settings['retailcrm_summ_around']) ||
|
||||||
|
$saved_settings['retailcrm_summ_around'] == 0) :
|
||||||
|
echo 'checked'; endif; ?> />
|
||||||
|
<?php echo $text_no; ?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<legend><?php echo $text_retailcrm_discount; ?></legend>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-2 control-label" for="label_discount"><?php echo $text_retailcrm_label_discount ?></label>
|
||||||
|
<div class="col-lg-4 col-md-6 col-sm-10">
|
||||||
|
<input name="retailcrm_label_discount" id="label_discount" class="form-control" value="<?php if (isset($saved_settings['retailcrm_label_discount'])): echo $saved_settings['retailcrm_label_discount']; else: echo $default_retailcrm_label_discount; endif ;?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<legend><?php echo $sum_payment; ?></legend>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-2 control-label" for="retailcrm_sum_payment"><?php echo $text_sum_payment?></label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<label class="radio-inline">
|
||||||
|
<input type="radio" name="retailcrm_sum_payment" value="1" <?php if (isset($saved_settings['retailcrm_sum_payment']) &&
|
||||||
|
$saved_settings['retailcrm_sum_payment'] == 1) :
|
||||||
|
echo 'checked'; endif;?> />
|
||||||
|
<?php echo $text_yes; ?>
|
||||||
|
</label>
|
||||||
|
<label class="radio-inline">
|
||||||
|
<input type="radio" name="retailcrm_sum_payment" value="0" <?php if (!isset($saved_settings['retailcrm_sum_payment']) ||
|
||||||
|
$saved_settings['retailcrm_sum_payment'] == 0) :
|
||||||
|
echo 'checked'; endif;?> />
|
||||||
|
<?php echo $text_no; ?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="tab-references">
|
<div class="tab-pane" id="tab-references">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
@ -456,6 +518,37 @@
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tab-pane" id="tab-consultant">
|
||||||
|
<fieldset>
|
||||||
|
<legend><?php echo $consultant_tab_text; ?></legend>
|
||||||
|
{* onlineConsultant *}
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-2 control-label" for="input-code"><?php echo $entry_code;?></label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<textarea name="retailcrm_online_consultant_code" rows="5" placeholder="<?php echo $entry_code;?>" id="retailcrm_entry_code" class="form-control">
|
||||||
|
<?php if (isset($saved_settings['retailcrm_online_consultant_code'])): echo $saved_settings['retailcrm_online_consultant_code']; endif;?>
|
||||||
|
</textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-2 control-label" for="retailcrm_online_consultant_active"><?php echo $entry_status; ?></label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<label class="radio-inline">
|
||||||
|
<input type="radio" name="retailcrm_online_consultant_active" value="1" <?php if (isset($saved_settings['retailcrm_online_consultant_active']) &&
|
||||||
|
$saved_settings['retailcrm_online_consultant_active'] == 1) :
|
||||||
|
echo 'checked'; endif; ?> />
|
||||||
|
<?php echo $text_yes; ?>
|
||||||
|
</label>
|
||||||
|
<label class="radio-inline">
|
||||||
|
<input type="radio" name="retailcrm_online_consultant_active" value="0" <?php if (!isset($saved_settings['retailcrm_online_consultant_active']) ||
|
||||||
|
$saved_settings['retailcrm_online_consultant_active'] == 0) :
|
||||||
|
echo 'checked'; endif; ?> />
|
||||||
|
<?php echo $text_no; ?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
<div class="tab-pane" id="tab-custom_fields">
|
<div class="tab-pane" id="tab-custom_fields">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><?php echo $retailcrm_dict_custom_fields; ?></legend>
|
<legend><?php echo $retailcrm_dict_custom_fields; ?></legend>
|
||||||
|
@ -545,7 +638,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="tab-logs">
|
<div class="tab-pane" id="tab-logs">
|
||||||
<fieldset style="margin-bottom: 30px;">
|
<fieldset style="margin-bottom: 30px;">
|
||||||
<legend>retailCRM API error log</legend>
|
<legend>RetailCRM API error log</legend>
|
||||||
<div class="retailcrm_unit">
|
<div class="retailcrm_unit">
|
||||||
<a onclick="confirm('<?php echo $text_confirm_log; ?>') ? location.href='<?php echo $clear_retailcrm; ?>' : false;" data-toggle="tooltip" title="<?php echo $button_clear; ?>" class="btn btn-danger"><i class="fa fa-eraser"></i> <span class="hidden-xs"><?php echo $button_clear; ?></span></a>
|
<a onclick="confirm('<?php echo $text_confirm_log; ?>') ? location.href='<?php echo $clear_retailcrm; ?>' : false;" data-toggle="tooltip" title="<?php echo $button_clear; ?>" class="btn btn-danger"><i class="fa fa-eraser"></i> <span class="hidden-xs"><?php echo $button_clear; ?></span></a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -655,3 +748,4 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<button type="button" id="icml" data-toggle="tooltip" title="{{ text_button_catalog }}" class="btn btn-success"><i class="fa fa-file-text-o"></i></button>
|
<button type="button" id="icml" data-toggle="tooltip" title="{{ text_button_catalog }}" class="btn btn-success"><i class="fa fa-file-text-o"></i></button>
|
||||||
<button type="submit" form="form-module" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fa fa-save"></i></button>
|
<button type="submit" form="form-module" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fa fa-save"></i></button>
|
||||||
<a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
|
<a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
|
||||||
<h1>{{ heading_title }}</h1>
|
<h1>{{ heading_title }} {{ module_version }}</h1>
|
||||||
<ul class="breadcrumb">
|
<ul class="breadcrumb">
|
||||||
{% for breadcrumb in breadcrumbs %}
|
{% for breadcrumb in breadcrumbs %}
|
||||||
<li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
|
<li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
|
||||||
|
@ -39,6 +39,7 @@
|
||||||
{% if saved_settings.module_retailcrm_apikey is defined and saved_settings.module_retailcrm_apikey and saved_settings.module_retailcrm_url is defined and saved_settings.module_retailcrm_url %}
|
{% if saved_settings.module_retailcrm_apikey is defined and saved_settings.module_retailcrm_apikey and saved_settings.module_retailcrm_url is defined and saved_settings.module_retailcrm_url %}
|
||||||
<li><a href="#tab-references" data-toggle="tab">{{ references_tab_text }}</a></li>
|
<li><a href="#tab-references" data-toggle="tab">{{ references_tab_text }}</a></li>
|
||||||
<li><a href="#tab-collector" data-toggle="tab">{{ collector_tab_text }}</a></li>
|
<li><a href="#tab-collector" data-toggle="tab">{{ collector_tab_text }}</a></li>
|
||||||
|
<li><a href="#tab-consultant" data-toggle="tab">{{ consultant_tab_text }}</a></li>
|
||||||
<li><a href="#tab-custom_fields" data-toggle="tab"> {{ custom_fields_tab_text }} </a></li>
|
<li><a href="#tab-custom_fields" data-toggle="tab"> {{ custom_fields_tab_text }} </a></li>
|
||||||
<li><a href="#tab-logs" data-toggle="tab">{{ logs_tab_text }}</a></li>
|
<li><a href="#tab-logs" data-toggle="tab">{{ logs_tab_text }}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -54,7 +55,7 @@
|
||||||
<input class="form-control" id="retailcrm_url" type="text" name="module_retailcrm_url" value="{% if saved_settings.module_retailcrm_url is defined %}{{ saved_settings.module_retailcrm_url }}{% endif %}">
|
<input class="form-control" id="retailcrm_url" type="text" name="module_retailcrm_url" value="{% if saved_settings.module_retailcrm_url is defined %}{{ saved_settings.module_retailcrm_url }}{% endif %}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group retailcrm_unit">
|
<div class="form-group retailcrm_unit retailcrm_disable_border">
|
||||||
<label class="col-sm-2 control-label" for="retailcrm_apikey">{{ retailcrm_apikey }}</label>
|
<label class="col-sm-2 control-label" for="retailcrm_apikey">{{ retailcrm_apikey }}</label>
|
||||||
<div class="col-lg-4 col-md-6 col-sm-10">
|
<div class="col-lg-4 col-md-6 col-sm-10">
|
||||||
<input class="form-control" id="retailcrm_apikey" type="text" name="module_retailcrm_apikey" value="{% if saved_settings.module_retailcrm_apikey is defined %}{{ saved_settings.module_retailcrm_apikey }}{% endif %}">
|
<input class="form-control" id="retailcrm_apikey" type="text" name="module_retailcrm_apikey" value="{% if saved_settings.module_retailcrm_apikey is defined %}{{ saved_settings.module_retailcrm_apikey }}{% endif %}">
|
||||||
|
@ -99,8 +100,27 @@
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{{ text_currency }}</legend>
|
<legend>{{ icml_settings }}</legend>
|
||||||
<div class="form-group retailcrm_unit">
|
<div class="form-group retailcrm_unit retailcrm_disable_border">
|
||||||
|
<label class="col-sm-2 control-label question-mark" for="module_retailcrm_icml_service_enabled" title="{{ icml_service_description }}">{{ icml_service_enabled_label }}</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<label class="radio-inline">
|
||||||
|
<input type="radio" name="module_retailcrm_icml_service_enabled" value="1"
|
||||||
|
{% if saved_settings.module_retailcrm_icml_service_enabled is defined and saved_settings.module_retailcrm_icml_service_enabled == 1 %}
|
||||||
|
checked
|
||||||
|
{% endif %} />
|
||||||
|
{{ text_yes }}
|
||||||
|
</label>
|
||||||
|
<label class="radio-inline">
|
||||||
|
<input type="radio" name="module_retailcrm_icml_service_enabled" value="0"
|
||||||
|
{% if saved_settings.module_retailcrm_icml_service_enabled is not defined or saved_settings.module_retailcrm_icml_service_enabled == 0 %}
|
||||||
|
checked
|
||||||
|
{% endif %} />
|
||||||
|
{{ text_no }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group retailcrm_unit retailcrm_disable_border">
|
||||||
<label class="col-sm-2 control-label">{{ text_currency_label }}</label>
|
<label class="col-sm-2 control-label">{{ text_currency_label }}</label>
|
||||||
<div class="col-md-4 col-sm-10">
|
<div class="col-md-4 col-sm-10">
|
||||||
<select id="module_retailcrm_currency" name="module_retailcrm_currency" class="form-control">
|
<select id="module_retailcrm_currency" name="module_retailcrm_currency" class="form-control">
|
||||||
|
@ -114,17 +134,14 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
<div class="form-group retailcrm_unit retailcrm_disable_border">
|
||||||
<fieldset>
|
|
||||||
<legend>{{ text_lenght }}</legend>
|
|
||||||
<div class="form-group retailcrm_unit">
|
|
||||||
<label class="col-sm-2 control-label">{{ text_lenght_label }}</label>
|
<label class="col-sm-2 control-label">{{ text_lenght_label }}</label>
|
||||||
<div class="col-md-4 col-sm-10">
|
<div class="col-md-4 col-sm-10">
|
||||||
<select id="module_retailcrm_lenght" name="module_retailcrm_lenght" class="form-control">
|
<select id="module_retailcrm_lenght" name="module_retailcrm_lenght" class="form-control">
|
||||||
{% for lenght in lenghts %}
|
{% for lenght in lenghts %}
|
||||||
<option value="{{ lenght.length_class_id }}" {% if saved_settings.module_retailcrm_lenght is defined and saved_settings.module_retailcrm_lenght == lenght.length_class_id %} selected="selected" {% endif %}>
|
<option value="{{ lenght.length_class_id }}" {% if saved_settings.module_retailcrm_lenght is defined and saved_settings.module_retailcrm_lenght == lenght.length_class_id %} selected="selected" {% endif %}>
|
||||||
{{ lenght.title }}
|
{{ lenght.title }}
|
||||||
</option>
|
</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -219,6 +236,59 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<legend>{{ summ_around }}</legend>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-2 control-label" class="col-sm-2 control-label" for="module_retailcrm_summ_around">{{ text_summ_around }}</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<label class="control-label" class="radio-inline">
|
||||||
|
<input type="radio" name="module_retailcrm_summ_around" value="1"
|
||||||
|
{% if saved_settings.module_retailcrm_summ_around is defined and saved_settings.module_retailcrm_summ_around == 1 %}
|
||||||
|
checked
|
||||||
|
{% endif %} />
|
||||||
|
{{ text_yes }}
|
||||||
|
</label>
|
||||||
|
<label class="control-label" class="radio-inline">
|
||||||
|
<input type="radio" name="module_retailcrm_summ_around" value="0"
|
||||||
|
{% if saved_settings.module_retailcrm_summ_around is not defined or saved_settings.module_retailcrm_summ_around == 0 %}
|
||||||
|
checked
|
||||||
|
{% endif %} />
|
||||||
|
{{ text_no }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<legend>{{ text_retailcrm_discount }}</legend>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-2 control-label" for="label_discount">{{ text_retailcrm_label_discount }}</label>
|
||||||
|
<div class="col-lg-4 col-md-6 col-sm-10">
|
||||||
|
<input name="module_retailcrm_label_discount" id="label_discount" class="form-control" value="{% if saved_settings.module_retailcrm_label_discount is defined %}{{ saved_settings.module_retailcrm_label_discount }}{% else %}{{ default_retailcrm_label_discount }}{% endif %}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<legend>{{ sum_payment }}</legend>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-2 control-label" for="module_retailcrm_sum_payment">{{ text_sum_payment }}</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<label class="control-label radio-inline">
|
||||||
|
<input type="radio" name="module_retailcrm_sum_payment" value="1"
|
||||||
|
{% if saved_settings.module_retailcrm_sum_payment is defined and saved_settings.module_retailcrm_sum_payment == 1 %}
|
||||||
|
checked
|
||||||
|
{% endif %} >
|
||||||
|
{{ text_yes }}
|
||||||
|
</label>
|
||||||
|
<label class="control-label radio-inline">
|
||||||
|
<input type="radio" name="module_retailcrm_sum_payment" value="0"
|
||||||
|
{% if saved_settings.module_retailcrm_sum_payment is not defined or saved_settings.module_retailcrm_sum_payment == 0 %}
|
||||||
|
checked
|
||||||
|
{% endif %} >
|
||||||
|
{{ text_no }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="tab-references">
|
<div class="tab-pane" id="tab-references">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
@ -465,6 +535,38 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tab-pane" id="tab-consultant">
|
||||||
|
<legend>{{ consultant_tab_text }}</legend>
|
||||||
|
<fieldset>
|
||||||
|
{# online cosultant #}
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-2 control-label" for="input-code">{{ entry_code }}</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<textarea name="module_retailcrm_online_consultant_code" rows="5" placeholder="{{ entry_code }}" id="retailcrm_entry_code" class="form-control">
|
||||||
|
{% if saved_settings.module_retailcrm_online_consultant_code is defined %}
|
||||||
|
{{ saved_settings.module_retailcrm_online_consultant_code }}{% endif %}
|
||||||
|
</textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-2 control-label" for="retailcrm_online_consultant_active" class="col-md-4">{{ entry_status }}</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<label class="control-label" class="radio-inline">
|
||||||
|
<input type="radio" name="module_retailcrm_online_consultant_active" value="1" {% if saved_settings.module_retailcrm_online_consultant_active is defined and
|
||||||
|
saved_settings.module_retailcrm_online_consultant_active == 1 %} {{ 'checked' }}
|
||||||
|
{% endif %}>
|
||||||
|
{{ text_yes }}
|
||||||
|
</label>
|
||||||
|
<label class="control-label" class="radio-inline">
|
||||||
|
<input type="radio" name="module_retailcrm_online_consultant_active" value="0" {% if not saved_settings.module_retailcrm_online_consultant_active or
|
||||||
|
saved_settings.module_retailcrm_online_consultant_active == 0 %} {{ 'checked' }}
|
||||||
|
{% endif %}>
|
||||||
|
{{ text_no }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
<div class="tab-pane" id="tab-custom_fields">
|
<div class="tab-pane" id="tab-custom_fields">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{{ retailcrm_dict_custom_fields }}</legend>
|
<legend>{{ retailcrm_dict_custom_fields }}</legend>
|
||||||
|
@ -665,3 +767,4 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -77,8 +77,8 @@ class ControllerApiRetailcrm extends Controller
|
||||||
$address = array(
|
$address = array(
|
||||||
'country_id' => $country_id,
|
'country_id' => $country_id,
|
||||||
'zone_id' => $zone['zone_id'],
|
'zone_id' => $zone['zone_id'],
|
||||||
'iso_code_2' => $country['iso_code_2'],
|
'iso_code_2' => $country['iso_code_2'] ?? '',
|
||||||
'iso_code_3' => $country['iso_code_3'],
|
'iso_code_3' => $country['iso_code_3'] ?? '',
|
||||||
'zone_code' => $zone['code'],
|
'zone_code' => $zone['code'],
|
||||||
'postcode' => '',
|
'postcode' => '',
|
||||||
'city' => ''
|
'city' => ''
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class ControllerExtensionAnalyticsDaemonCollector extends Controller {
|
class ControllerExtensionAnalyticsDaemonCollector extends Controller {
|
||||||
public function index() {
|
public function index() {
|
||||||
$this->load->model('setting/setting');
|
$this->load->model('setting/setting');
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class ControllerExtensionAnalyticsOnlineConsultant extends Controller {
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function index() {
|
||||||
|
$this->load->model('setting/setting');
|
||||||
|
$this->load->library('retailcrm/retailcrm');
|
||||||
|
|
||||||
|
$moduleTitle = $this->retailcrm->getModuleTitle();
|
||||||
|
$settings = $this->model_setting_setting->getSetting($moduleTitle);
|
||||||
|
$setting = trim($settings['module_retailcrm_online_consultant_code']);
|
||||||
|
|
||||||
|
return html_entity_decode($setting, ENT_QUOTES, 'UTF-8');
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,14 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Class ControllerModule
|
|
||||||
*
|
|
||||||
* @category RetailCrm
|
|
||||||
* @package RetailCrm
|
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
|
||||||
*/
|
|
||||||
class ControllerExtensionModuleRetailcrm extends Controller {
|
class ControllerExtensionModuleRetailcrm extends Controller {
|
||||||
|
|
||||||
private $retailcrmApiClient;
|
private $retailcrmApiClient;
|
||||||
|
@ -59,6 +50,9 @@ class ControllerExtensionModuleRetailcrm extends Controller {
|
||||||
|
|
||||||
if (file_exists(DIR_APPLICATION . 'model/extension/retailcrm/custom/order.php')) {
|
if (file_exists(DIR_APPLICATION . 'model/extension/retailcrm/custom/order.php')) {
|
||||||
$this->load->model('extension/retailcrm/custom/order');
|
$this->load->model('extension/retailcrm/custom/order');
|
||||||
|
$order_data['products'] = $products;
|
||||||
|
$order_data['totals'] = $totals;
|
||||||
|
|
||||||
$order = $this->model_extension_retailcrm_custom_order->processOrder($order_data);
|
$order = $this->model_extension_retailcrm_custom_order->processOrder($order_data);
|
||||||
$this->model_extension_retailcrm_custom_order->sendToCrm($order, $this->retailcrmApiClient, $order_data);
|
$this->model_extension_retailcrm_custom_order->sendToCrm($order, $this->retailcrmApiClient, $order_data);
|
||||||
} else {
|
} else {
|
||||||
|
@ -111,6 +105,9 @@ class ControllerExtensionModuleRetailcrm extends Controller {
|
||||||
|
|
||||||
if (file_exists(DIR_APPLICATION . 'model/extension/retailcrm/custom/order.php')) {
|
if (file_exists(DIR_APPLICATION . 'model/extension/retailcrm/custom/order.php')) {
|
||||||
$this->load->model('extension/retailcrm/custom/order');
|
$this->load->model('extension/retailcrm/custom/order');
|
||||||
|
$data['products'] = $products;
|
||||||
|
$data['totals'] = $totals;
|
||||||
|
|
||||||
$order = $this->model_extension_retailcrm_custom_order->processOrder($data, false);
|
$order = $this->model_extension_retailcrm_custom_order->processOrder($data, false);
|
||||||
$this->model_extension_retailcrm_custom_order->sendToCrm($order, $this->retailcrmApiClient, $data, false);
|
$this->model_extension_retailcrm_custom_order->sendToCrm($order, $this->retailcrmApiClient, $data, false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -141,6 +138,20 @@ class ControllerExtensionModuleRetailcrm extends Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function customer_edit_newsletter($parameter1, $parameter2, $parameter3)
|
||||||
|
{
|
||||||
|
$customerId = $this->customer->getId();
|
||||||
|
$customer = $this->model_account_customer->getCustomer($customerId);
|
||||||
|
|
||||||
|
if (file_exists(DIR_APPLICATION . 'model/extension/retailcrm/custom/customer.php')) {
|
||||||
|
$this->load->model('extension/retailcrm/custom/customer');
|
||||||
|
$this->model_extension_retailcrm_custom_customer->changeInCrm($customer, $this->retailcrmApiClient);
|
||||||
|
} else {
|
||||||
|
$customer_manager = $this->retailcrm->getCustomerManager();
|
||||||
|
$customer_manager->editCustomerNewsLetter($customer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update customer on event
|
* Update customer on event
|
||||||
*
|
*
|
||||||
|
|
|
@ -68,7 +68,7 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||||
$response = $retailcrmApiClient->ordersEdit($order);
|
$response = $retailcrmApiClient->ordersEdit($order);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->settings[$this->moduleTitle . '_apiversion'] == 'v5' && $response->isSuccessful()) {
|
if ($response->isSuccessful()) {
|
||||||
$this->updatePayment($order_payment, $order['externalId'], $retailcrmApiClient);
|
$this->updatePayment($order_payment, $order['externalId'], $retailcrmApiClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,12 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||||
$order['number'] = $order_data['order_id'];
|
$order['number'] = $order_data['order_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($this->settings[$this->moduleTitle . '_summ_around'])
|
||||||
|
&& $this->settings[$this->moduleTitle . '_summ_around'] == 1
|
||||||
|
) {
|
||||||
|
$order['applyRound'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
$order['externalId'] = $order_id;
|
$order['externalId'] = $order_id;
|
||||||
$order['firstName'] = $order_data['shipping_firstname'];
|
$order['firstName'] = $order_data['shipping_firstname'];
|
||||||
$order['lastName'] = $order_data['shipping_lastname'];
|
$order['lastName'] = $order_data['shipping_lastname'];
|
||||||
|
@ -169,16 +175,8 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||||
}
|
}
|
||||||
|
|
||||||
$order['createdAt'] = $order_data['date_added'];
|
$order['createdAt'] = $order_data['date_added'];
|
||||||
|
if ($couponTotal > 0) {
|
||||||
if ($this->settings[$this->moduleTitle . '_apiversion'] != 'v5') {
|
$order['discountManualAmount'] = $couponTotal;
|
||||||
$order['paymentType'] = $payment_code;
|
|
||||||
if ($couponTotal > 0) {
|
|
||||||
$order['discount'] = $couponTotal;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($couponTotal > 0) {
|
|
||||||
$order['discountManualAmount'] = $couponTotal;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$country = isset($order_data['shipping_country']) ? $order_data['shipping_country'] : '' ;
|
$country = isset($order_data['shipping_country']) ? $order_data['shipping_country'] : '' ;
|
||||||
|
@ -245,71 +243,69 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||||
$offerId = implode('_', $offerId);
|
$offerId = implode('_', $offerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->settings[$this->moduleTitle . '_apiversion'] != 'v3') {
|
$item = array(
|
||||||
$item = array(
|
'offer' => array(
|
||||||
'offer' => array(
|
'externalId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id']
|
||||||
'externalId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id']
|
),
|
||||||
),
|
'productName' => $product['name'],
|
||||||
'productName' => $product['name'],
|
'initialPrice' => $product['price'],
|
||||||
'initialPrice' => $product['price'],
|
'quantity' => $product['quantity']
|
||||||
'quantity' => $product['quantity']
|
);
|
||||||
);
|
|
||||||
|
|
||||||
$specials = $this->model_extension_retailcrm_product->getProductSpecials($product['product_id']);
|
$specials = $this->model_extension_retailcrm_product->getProductSpecials($product['product_id']);
|
||||||
|
|
||||||
if (!empty($specials)) {
|
if (!empty($specials)) {
|
||||||
$customer = $this->model_account_customer->getCustomer($order_data['customer_id']);
|
$customer = $this->model_account_customer->getCustomer($order_data['customer_id']);
|
||||||
|
|
||||||
foreach ($specials as $special) {
|
foreach ($specials as $special) {
|
||||||
if (isset($customer['customer_group_id'])) {
|
if (isset($customer['customer_group_id'])) {
|
||||||
if ($special['customer_group_id'] == $customer['customer_group_id']) {
|
if ($special['customer_group_id'] == $customer['customer_group_id']) {
|
||||||
if ($this->settings[$this->moduleTitle . '_special_' . $customer['customer_group_id']]) {
|
if ($this->settings[$this->moduleTitle . '_special_' . $customer['customer_group_id']]) {
|
||||||
$item['priceType']['code'] = $this->settings[$this->moduleTitle . '_special_' . $customer['customer_group_id']];
|
$item['priceType']['code'] = $this->settings[$this->moduleTitle . '_special_' . $customer['customer_group_id']];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$item = array(
|
|
||||||
'productName' => $product['name'],
|
|
||||||
'initialPrice' => $product['price'],
|
|
||||||
'quantity' => $product['quantity'],
|
|
||||||
'productId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id']
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($properties)) $item['properties'] = $properties;
|
if (isset($properties)) $item['properties'] = $properties;
|
||||||
|
|
||||||
$order['items'][] = $item;
|
$order['items'][] = $item;
|
||||||
|
|
||||||
if (isset($order_data['order_status_id']) && $order_data['order_status_id'] > 0) {
|
|
||||||
$order['status'] = $this->settings[$this->moduleTitle . '_status'][$order_data['order_status_id']];
|
|
||||||
} elseif (isset($order_data['order_status_id']) && $order_data['order_status_id'] == 0) {
|
|
||||||
$order['status'] = $this->settings[$this->moduleTitle . '_missing_status'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($this->settings[$this->moduleTitle . '_custom_field']) && $order_data['custom_field']) {
|
|
||||||
$customFields = $order_data['custom_field'];
|
|
||||||
|
|
||||||
foreach ($customFields as $key => $value) {
|
|
||||||
if (isset($this->settings[$this->moduleTitle . '_custom_field']['o_' . $key])) {
|
|
||||||
$customFieldsToCrm[$this->settings[$this->moduleTitle . '_custom_field']['o_' . $key]] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($customFieldsToCrm)) {
|
|
||||||
$order['customFields'] = $customFieldsToCrm;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (isset($order_data['order_status_id']) && $order_data['order_status_id'] > 0) {
|
||||||
|
$order['status'] = $this->settings[$this->moduleTitle . '_status'][$order_data['order_status_id']];
|
||||||
|
} elseif (isset($order_data['order_status_id']) && $order_data['order_status_id'] == 0) {
|
||||||
|
$order['status'] = $this->settings[$this->moduleTitle . '_missing_status'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($this->settings[$this->moduleTitle . '_custom_field']) && $order_data['custom_field']) {
|
||||||
|
$customFields = $order_data['custom_field'];
|
||||||
|
|
||||||
|
foreach ($customFields as $key => $value) {
|
||||||
|
if (isset($this->settings[$this->moduleTitle . '_custom_field']['o_' . $key])) {
|
||||||
|
$customFieldsToCrm[$this->settings[$this->moduleTitle . '_custom_field']['o_' . $key]] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($customFieldsToCrm)) {
|
||||||
|
$order['customFields'] = $customFieldsToCrm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$payment = array(
|
$payment = array(
|
||||||
'externalId' => $order_id,
|
'externalId' => $order_id,
|
||||||
'type' => $payment_code,
|
'type' => $payment_code,
|
||||||
'amount' => $totals['total']
|
'amount' => $totals['total']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (isset($this->settings[$this->moduleTitle . '_sum_payment']) &&
|
||||||
|
$this->settings[$this->moduleTitle . '_sum_payment'] == 1
|
||||||
|
) {
|
||||||
|
unset($payment['amount']);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$create) {
|
if (!$create) {
|
||||||
$payment['order'] = array(
|
$payment['order'] = array(
|
||||||
'externalId' => $order_id
|
'externalId' => $order_id
|
||||||
|
@ -430,6 +426,7 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||||
'lastName' => $data['lastname'],
|
'lastName' => $data['lastname'],
|
||||||
'email' => $data['email'],
|
'email' => $data['email'],
|
||||||
'createdAt' => $data['date_added'],
|
'createdAt' => $data['date_added'],
|
||||||
|
'externalId' => $data['customer_id'],
|
||||||
'address' => array(
|
'address' => array(
|
||||||
'countryIso' => $data['payment_iso_code_2'],
|
'countryIso' => $data['payment_iso_code_2'],
|
||||||
'index' => $data['payment_postcode'],
|
'index' => $data['payment_postcode'],
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ModelExtensionTotalRetailcrmDiscount
|
||||||
|
*
|
||||||
|
* This class is unused in this module but used inside opencart as stub in file "catalog/model/checkout/order.php"
|
||||||
|
* in method addOrderHistory()
|
||||||
|
*/
|
||||||
|
class ModelExtensionTotalRetailcrmDiscount extends Model
|
||||||
|
{
|
||||||
|
}
|
|
@ -12,7 +12,7 @@ if (!isset($cli_action)) {
|
||||||
|
|
||||||
// Version
|
// Version
|
||||||
$version = '2.3.0';
|
$version = '2.3.0';
|
||||||
$indexFile = file_get_contents(realpath(dirname(__FILE__)) . '/../../index.php');
|
$indexFile = file_get_contents(realpath(dirname(__FILE__)) . '/../../../../index.php');
|
||||||
preg_match("/define\([\s]*['\"]VERSION['\"][\s]*,[\s]*['\"](.*)['\"][\s]*\)[\s]*;/mi", $indexFile, $versionMatches);
|
preg_match("/define\([\s]*['\"]VERSION['\"][\s]*,[\s]*['\"](.*)['\"][\s]*\)[\s]*;/mi", $indexFile, $versionMatches);
|
||||||
|
|
||||||
if (isset($versionMatches[1])) {
|
if (isset($versionMatches[1])) {
|
||||||
|
@ -22,7 +22,7 @@ if (isset($versionMatches[1])) {
|
||||||
define('VERSION', $version);
|
define('VERSION', $version);
|
||||||
|
|
||||||
// Configuration (note we're using the admin config)
|
// Configuration (note we're using the admin config)
|
||||||
require_once(realpath(dirname(__FILE__)) . '/../../admin/config.php');
|
require_once(realpath(dirname(__FILE__)) . '/../../../../admin/config.php');
|
||||||
|
|
||||||
// Configuration check
|
// Configuration check
|
||||||
if (!defined('DIR_APPLICATION')) {
|
if (!defined('DIR_APPLICATION')) {
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* PHP version 5.3
|
|
||||||
*
|
|
||||||
* Class CurlException
|
|
||||||
*
|
|
||||||
* @category RetailCrm
|
|
||||||
* @package RetailCrm
|
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
|
||||||
*/
|
|
||||||
class CurlException extends RuntimeException
|
class CurlException extends RuntimeException
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* PHP version 5.3
|
|
||||||
*
|
|
||||||
* Class InvalidJsonException
|
|
||||||
*
|
|
||||||
* @category RetailCrm
|
|
||||||
* @package RetailCrm
|
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
|
||||||
*/
|
|
||||||
class InvalidJsonException extends DomainException
|
class InvalidJsonException extends DomainException
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ class OpencartApiClient {
|
||||||
|
|
||||||
$cookies = array();
|
$cookies = array();
|
||||||
foreach ($cookieFile as $line) {
|
foreach ($cookieFile as $line) {
|
||||||
if (empty($line) OR $line{0} == '#') {
|
if (empty($line) OR $line[0] == '#') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* PHP version 5.3
|
|
||||||
*
|
|
||||||
* API client class
|
|
||||||
*
|
|
||||||
* @category RetailCrm
|
|
||||||
* @package RetailCrm
|
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
|
||||||
*/
|
|
||||||
class RetailcrmApiClient5
|
class RetailcrmApiClient5
|
||||||
{
|
{
|
||||||
const VERSION = 'v5';
|
const VERSION = 'v5';
|
||||||
|
@ -594,30 +584,18 @@ class RetailcrmApiClient5
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get orders history
|
* Get orders history
|
||||||
|
*
|
||||||
* @param array $filter
|
* @param array $filter
|
||||||
* @param null $page
|
* @param int|null $limit
|
||||||
* @param null $limit
|
|
||||||
*
|
*
|
||||||
* @return ApiResponse
|
* @return ApiResponse
|
||||||
*/
|
*/
|
||||||
public function ordersHistory(array $filter = array(), $page = null, $limit = null)
|
public function ordersHistory(array $filter = [], ?int $limit = 100)
|
||||||
{
|
{
|
||||||
$parameters = array();
|
|
||||||
|
|
||||||
if (count($filter)) {
|
|
||||||
$parameters['filter'] = $filter;
|
|
||||||
}
|
|
||||||
if (null !== $page) {
|
|
||||||
$parameters['page'] = (int) $page;
|
|
||||||
}
|
|
||||||
if (null !== $limit) {
|
|
||||||
$parameters['limit'] = (int) $limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->client->makeRequest(
|
return $this->client->makeRequest(
|
||||||
'/orders/history',
|
'/orders/history',
|
||||||
RetailcrmHttpClient::METHOD_GET,
|
RetailcrmHttpClient::METHOD_GET,
|
||||||
$parameters
|
['filter' => $filter, 'limit' => $limit]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -918,30 +896,18 @@ class RetailcrmApiClient5
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get customers history
|
* Get customers history
|
||||||
|
*
|
||||||
* @param array $filter
|
* @param array $filter
|
||||||
* @param null $page
|
* @param int|null $limit
|
||||||
* @param null $limit
|
|
||||||
*
|
*
|
||||||
* @return ApiResponse
|
* @return ApiResponse
|
||||||
*/
|
*/
|
||||||
public function customersHistory(array $filter = array(), $page = null, $limit = null)
|
public function customersHistory(array $filter = [], ?int $limit = 100)
|
||||||
{
|
{
|
||||||
$parameters = array();
|
|
||||||
|
|
||||||
if (count($filter)) {
|
|
||||||
$parameters['filter'] = $filter;
|
|
||||||
}
|
|
||||||
if (null !== $page) {
|
|
||||||
$parameters['page'] = (int) $page;
|
|
||||||
}
|
|
||||||
if (null !== $limit) {
|
|
||||||
$parameters['limit'] = (int) $limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->client->makeRequest(
|
return $this->client->makeRequest(
|
||||||
'/customers/history',
|
'/customers/history',
|
||||||
RetailcrmHttpClient::METHOD_GET,
|
RetailcrmHttpClient::METHOD_GET,
|
||||||
$parameters
|
['filter' => $filter, 'limit' => $limit]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1118,34 +1084,17 @@ class RetailcrmApiClient5
|
||||||
/**
|
/**
|
||||||
* Get orders assembly history
|
* Get orders assembly history
|
||||||
*
|
*
|
||||||
* @param array $filter (default: array())
|
* @param array $filter
|
||||||
* @param int $page (default: null)
|
* @param int|null $limit
|
||||||
* @param int $limit (default: null)
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
* @throws \RetailCrm\Exception\CurlException
|
|
||||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
||||||
*
|
*
|
||||||
* @return ApiResponse
|
* @return ApiResponse
|
||||||
*/
|
*/
|
||||||
public function ordersPacksHistory(array $filter = array(), $page = null, $limit = null)
|
public function ordersPacksHistory(array $filter = [], ?int $limit = 100)
|
||||||
{
|
{
|
||||||
$parameters = array();
|
|
||||||
|
|
||||||
if (count($filter)) {
|
|
||||||
$parameters['filter'] = $filter;
|
|
||||||
}
|
|
||||||
if (null !== $page) {
|
|
||||||
$parameters['page'] = (int) $page;
|
|
||||||
}
|
|
||||||
if (null !== $limit) {
|
|
||||||
$parameters['limit'] = (int) $limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->client->makeRequest(
|
return $this->client->makeRequest(
|
||||||
'/orders/packs/history',
|
'/orders/packs/history',
|
||||||
RetailcrmHttpClient::METHOD_GET,
|
RetailcrmHttpClient::METHOD_GET,
|
||||||
$parameters
|
['filter' => $filter, 'limit' => $limit]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2462,30 +2411,18 @@ class RetailcrmApiClient5
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get corporate customers history
|
* Get corporate customers history
|
||||||
* @param array $filter
|
|
||||||
* @param null $page
|
|
||||||
* @param null $limit
|
|
||||||
*
|
*
|
||||||
* @return \ApiResponse
|
* @param array $filter
|
||||||
|
* @param int|null $limit
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
*/
|
*/
|
||||||
public function customersCorporateHistory(array $filter = [], $page = null, $limit = null)
|
public function customersCorporateHistory(array $filter = [], ?int $limit = 100)
|
||||||
{
|
{
|
||||||
$parameters = [];
|
|
||||||
|
|
||||||
if (count($filter)) {
|
|
||||||
$parameters['filter'] = $filter;
|
|
||||||
}
|
|
||||||
if (null !== $page) {
|
|
||||||
$parameters['page'] = (int) $page;
|
|
||||||
}
|
|
||||||
if (null !== $limit) {
|
|
||||||
$parameters['limit'] = (int) $limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->client->makeRequest(
|
return $this->client->makeRequest(
|
||||||
'/customers-corporate/history',
|
'/customers-corporate/history',
|
||||||
RetailcrmHttpClient::METHOD_GET,
|
RetailcrmHttpClient::METHOD_GET,
|
||||||
$parameters
|
['filter' => $filter, 'limit' => $limit]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* PHP version 5.3
|
|
||||||
*
|
|
||||||
* Response from retailCRM API
|
|
||||||
*
|
|
||||||
* @category RetailCrm
|
|
||||||
* @package RetailCrm
|
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
|
||||||
*/
|
|
||||||
class RetailcrmApiResponse implements ArrayAccess
|
class RetailcrmApiResponse implements ArrayAccess
|
||||||
{
|
{
|
||||||
// HTTP response status code
|
// HTTP response status code
|
||||||
|
|
|
@ -1,15 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* PHP version 5.3
|
use retailcrm\Retailcrm;
|
||||||
*
|
|
||||||
* HTTP client
|
|
||||||
*
|
|
||||||
* @category RetailCrm
|
|
||||||
* @package RetailCrm
|
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
|
||||||
*/
|
|
||||||
class RetailcrmHttpClient
|
class RetailcrmHttpClient
|
||||||
{
|
{
|
||||||
const METHOD_GET = 'GET';
|
const METHOD_GET = 'GET';
|
||||||
|
@ -56,9 +48,9 @@ class RetailcrmHttpClient
|
||||||
public function makeRequest(
|
public function makeRequest(
|
||||||
$path,
|
$path,
|
||||||
$method,
|
$method,
|
||||||
array $parameters = array()
|
array $parameters = []
|
||||||
) {
|
) {
|
||||||
$allowedMethods = array(self::METHOD_GET, self::METHOD_POST);
|
$allowedMethods = [self::METHOD_GET, self::METHOD_POST];
|
||||||
|
|
||||||
if (!in_array($method, $allowedMethods, false)) {
|
if (!in_array($method, $allowedMethods, false)) {
|
||||||
throw new \InvalidArgumentException(
|
throw new \InvalidArgumentException(
|
||||||
|
@ -70,7 +62,16 @@ class RetailcrmHttpClient
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$parameters = array_merge($this->defaultParameters, $parameters);
|
|
||||||
|
$parameters = self::METHOD_GET === $method
|
||||||
|
? array_merge($this->defaultParameters, $parameters, [
|
||||||
|
'cms_source' => 'OpenCart',
|
||||||
|
'cms_version' => VERSION,
|
||||||
|
'php_version' => function_exists('phpversion') ? phpversion() : '',
|
||||||
|
'module_version' => Retailcrm::VERSION_MODULE,
|
||||||
|
])
|
||||||
|
: $parameters = array_merge($this->defaultParameters, $parameters);
|
||||||
|
|
||||||
|
|
||||||
$url = $this->url . $path;
|
$url = $this->url . $path;
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,11 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RequestProxy
|
* Class RequestProxy
|
||||||
* @package RetailCrm\Component
|
|
||||||
*
|
*
|
||||||
* @method ordersCreate($order, $site = null)
|
* @method ordersCreate($order, $site = null)
|
||||||
* @method ordersEdit($order, $by = 'externalId', $site = null)
|
* @method ordersEdit($order, $by = 'externalId', $site = null)
|
||||||
* @method ordersGet($order, $by = 'externalId', $site = null)
|
* @method ordersGet($order, $by = 'externalId', $site = null)
|
||||||
* @method ordersList($filter, $page, $limit)
|
* @method ordersList(array $filter = [], $page = null, $limit = null)
|
||||||
* @method customersCreate($customer, $site = null)
|
* @method customersCreate($customer, $site = null)
|
||||||
* @method customersEdit($customer, $by = 'externalId', $site = null)
|
* @method customersEdit($customer, $by = 'externalId', $site = null)
|
||||||
* @method customersList(array $filter = [], $page = null, $limit = null)
|
* @method customersList(array $filter = [], $page = null, $limit = null)
|
||||||
|
@ -28,16 +27,16 @@ class RetailcrmProxy {
|
||||||
|
|
||||||
public function __construct($url, $key) {
|
public function __construct($url, $key) {
|
||||||
$this->api = new RetailcrmApiClient5($url, $key);
|
$this->api = new RetailcrmApiClient5($url, $key);
|
||||||
|
|
||||||
$this->log = new \Log('retailcrm.log');
|
$this->log = new \Log('retailcrm.log');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __call($method, $arguments) {
|
public function __call($method, $arguments) {
|
||||||
try {
|
try {
|
||||||
$response = call_user_func_array(array($this->api, $method), $arguments);
|
$response = call_user_func_array([$this->api, $method], $arguments);
|
||||||
|
|
||||||
if (!$response->isSuccessful()) {
|
if (!$response->isSuccessful()) {
|
||||||
$this->log->write(sprintf("[%s] %s", $method, $response->getErrorMsg()));
|
$this->log->write(sprintf("[%s] %s", $method, $response->getErrorMsg()));
|
||||||
|
|
||||||
if (isset($response['errors'])) {
|
if (isset($response['errors'])) {
|
||||||
$error = implode("\n", $response['errors']);
|
$error = implode("\n", $response['errors']);
|
||||||
$this->log->write($error . "\n");
|
$this->log->write($error . "\n");
|
||||||
|
|
|
@ -38,10 +38,14 @@ class Customer {
|
||||||
}
|
}
|
||||||
|
|
||||||
$customer_data['firstname'] = $customer['firstName'];
|
$customer_data['firstname'] = $customer['firstName'];
|
||||||
$customer_data['lastname'] = isset($customer['lastName']) ? $customer['lastName'] : '';
|
$customer_data['lastname'] = $customer['lastName'] ?? '';
|
||||||
$customer_data['email'] = $customer['email'];
|
$customer_data['email'] = $customer['email'];
|
||||||
$customer_data['telephone'] = $customer['phones'] ? $customer['phones'][0]['number'] : '';
|
$customer_data['telephone'] = $customer['phones'] ? $customer['phones'][0]['number'] : '';
|
||||||
|
|
||||||
|
if (!empty($customer['emailMarketingUnsubscribedAt'])) {
|
||||||
|
$customer_data['newsletter'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$customer_data['affiliate'] = false;
|
$customer_data['affiliate'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +57,9 @@ class Customer {
|
||||||
if ($address_id) {
|
if ($address_id) {
|
||||||
$customer_address = $this->customer_repository->getAddress($address_id);
|
$customer_address = $this->customer_repository->getAddress($address_id);
|
||||||
} else {
|
} else {
|
||||||
$customer_address = array();
|
$customer_address = array(
|
||||||
|
'address_id' => ''
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($customer['address']['countryIso'])) {
|
if (isset($customer['address']['countryIso'])) {
|
||||||
|
@ -107,7 +113,7 @@ class Customer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$customer_data['custom_field'] = isset($custom_fields) ? $custom_fields : '';
|
$customer_data['custom_field'] = $custom_fields ?? [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace retailcrm\history;
|
||||||
use retailcrm\repository\DataRepository;
|
use retailcrm\repository\DataRepository;
|
||||||
use retailcrm\repository\OrderRepository;
|
use retailcrm\repository\OrderRepository;
|
||||||
use retailcrm\repository\ProductsRepository;
|
use retailcrm\repository\ProductsRepository;
|
||||||
|
use retailcrm\Retailcrm;
|
||||||
use retailcrm\service\SettingsManager;
|
use retailcrm\service\SettingsManager;
|
||||||
|
|
||||||
class Order {
|
class Order {
|
||||||
|
@ -43,7 +44,7 @@ class Order {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data opencart order
|
* @param array $data opencart order
|
||||||
* @param array $order retailCRM order
|
* @param array $order RetailCRM order
|
||||||
*/
|
*/
|
||||||
public function handleBaseOrderData(&$data, $order) {
|
public function handleBaseOrderData(&$data, $order) {
|
||||||
$mail = !empty($order['email']) ? $order['email'] : $order['customer']['email'];
|
$mail = !empty($order['email']) ? $order['email'] : $order['customer']['email'];
|
||||||
|
@ -88,7 +89,7 @@ class Order {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data opencart order
|
* @param array $data opencart order
|
||||||
* @param array $order retailCRM order
|
* @param array $order RetailCRM order
|
||||||
* @param array $corporateAddress
|
* @param array $corporateAddress
|
||||||
*/
|
*/
|
||||||
public function handlePayment(&$data, $order, $corporateAddress = array()) {
|
public function handlePayment(&$data, $order, $corporateAddress = array()) {
|
||||||
|
@ -156,7 +157,7 @@ class Order {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data opencart order
|
* @param array $data opencart order
|
||||||
* @param array $order retailCRM order
|
* @param array $order RetailCRM order
|
||||||
*/
|
*/
|
||||||
public function handleShipping(&$data, $order) {
|
public function handleShipping(&$data, $order) {
|
||||||
$default_shipping_country = !empty($data['shipping_country']) ? $data['shipping_country'] : '';
|
$default_shipping_country = !empty($data['shipping_country']) ? $data['shipping_country'] : '';
|
||||||
|
@ -208,7 +209,7 @@ class Order {
|
||||||
$shipping = explode('.', $data['shipping_code']);
|
$shipping = explode('.', $data['shipping_code']);
|
||||||
$shippingModule = $shipping[0];
|
$shippingModule = $shipping[0];
|
||||||
|
|
||||||
if (isset($this->ocDelivery[$shippingModule][$data['shipping_code']]['title'])) {
|
if (isset($this->oc_delivery[$shippingModule][$data['shipping_code']]['title'])) {
|
||||||
$data['shipping_method'] = $this->oc_delivery[$shippingModule][$data['shipping_code']]['title'];
|
$data['shipping_method'] = $this->oc_delivery[$shippingModule][$data['shipping_code']]['title'];
|
||||||
} else {
|
} else {
|
||||||
$data['shipping_method'] = $this->oc_delivery[$shippingModule]['title'];
|
$data['shipping_method'] = $this->oc_delivery[$shippingModule]['title'];
|
||||||
|
@ -220,7 +221,7 @@ class Order {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data opencart order
|
* @param array $data opencart order
|
||||||
* @param array $order retailCRM order
|
* @param array $order RetailCRM order
|
||||||
*/
|
*/
|
||||||
public function handleProducts(&$data, $order) {
|
public function handleProducts(&$data, $order) {
|
||||||
$data['order_product'] = array();
|
$data['order_product'] = array();
|
||||||
|
@ -229,7 +230,7 @@ class Order {
|
||||||
$product_id = $item['offer']['externalId'];
|
$product_id = $item['offer']['externalId'];
|
||||||
$options = array();
|
$options = array();
|
||||||
|
|
||||||
if (mb_strpos($item['offer']['externalId'], '#') > 1) {
|
if (mb_strpos($item['offer']['externalId'], '#', 0, mb_internal_encoding()) > 1) {
|
||||||
$offer = explode('#', $item['offer']['externalId']);
|
$offer = explode('#', $item['offer']['externalId']);
|
||||||
$product_id = $offer[0];
|
$product_id = $offer[0];
|
||||||
$options_from_crm = explode('_', $offer[1]);
|
$options_from_crm = explode('_', $offer[1]);
|
||||||
|
@ -277,7 +278,7 @@ class Order {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data opencart order
|
* @param array $data opencart order
|
||||||
* @param array $order retailCRM order
|
* @param array $order RetailCRM order
|
||||||
*/
|
*/
|
||||||
public function handleTotals(&$data, $order) {
|
public function handleTotals(&$data, $order) {
|
||||||
$delivery_cost = !empty($order['delivery']['cost']) ? $order['delivery']['cost'] : 0;
|
$delivery_cost = !empty($order['delivery']['cost']) ? $order['delivery']['cost'] : 0;
|
||||||
|
@ -285,6 +286,15 @@ class Order {
|
||||||
$subtotal_settings = $this->settings_manager->getSettingByKey($this->data_repository->totalTitles() . 'sub_total');
|
$subtotal_settings = $this->settings_manager->getSettingByKey($this->data_repository->totalTitles() . 'sub_total');
|
||||||
$total_settings = $this->settings_manager->getSettingByKey($this->data_repository->totalTitles() . 'total');
|
$total_settings = $this->settings_manager->getSettingByKey($this->data_repository->totalTitles() . 'total');
|
||||||
$shipping_settings = $this->settings_manager->getSettingByKey($this->data_repository->totalTitles() . 'shipping');
|
$shipping_settings = $this->settings_manager->getSettingByKey($this->data_repository->totalTitles() . 'shipping');
|
||||||
|
$retailcrm_label_discount = $this->settings_manager->getSetting('label_discount')
|
||||||
|
?: $this->data_repository->getLanguage('default_retailcrm_label_discount');
|
||||||
|
|
||||||
|
$totalDiscount = 0;
|
||||||
|
foreach ($order['items'] as $item) {
|
||||||
|
if ($item['discountTotal'] !== 0) {
|
||||||
|
$totalDiscount += $item['discountTotal'] * $item['quantity'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$data['total'] = $order['totalSumm'];
|
$data['total'] = $order['totalSumm'];
|
||||||
$data['order_total'] = array(
|
$data['order_total'] = array(
|
||||||
|
@ -314,21 +324,47 @@ class Order {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//TODO подкорректировать логику добавления скидки из RetailCRM
|
||||||
|
//Если заказ создали со скидкой в RetailCRM, то добавить скидку
|
||||||
|
if (!empty($totalDiscount)) {
|
||||||
|
$data['order_total'][] = array(
|
||||||
|
'order_total_id' => '',
|
||||||
|
'code' => Retailcrm::RETAILCRM_DISCOUNT,
|
||||||
|
'title' => $retailcrm_label_discount,
|
||||||
|
'value' => -$totalDiscount,
|
||||||
|
'sort_order' => Retailcrm::RETAILCRM_DISCOUNT_SORT_ORDER,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($order['externalId'])) {
|
if (!empty($order['externalId'])) {
|
||||||
$orderTotals = $this->order_repository->getOrderTotals($order['externalId']);
|
$orderTotals = $this->order_repository->getOrderTotals($order['externalId']);
|
||||||
|
|
||||||
foreach ($orderTotals as $orderTotal) {
|
foreach ($orderTotals as $orderTotal) {
|
||||||
if ($orderTotal['code'] == 'coupon'
|
if ($orderTotal['code'] == 'coupon'
|
||||||
|| $orderTotal['code'] == 'reward'
|
|| $orderTotal['code'] == 'reward'
|
||||||
|
|| $orderTotal['code'] == 'voucher'
|
||||||
) {
|
) {
|
||||||
$data['order_total'][] = $orderTotal;
|
$data['order_total'][] = $orderTotal;
|
||||||
|
$totalDiscount -= abs($orderTotal['value']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO подкорректировать логику добавления скидки из RetailCRM
|
||||||
|
$keyRetailCrmDiscount = array_search(Retailcrm::RETAILCRM_DISCOUNT, array_map(function ($item) {
|
||||||
|
return $item['code'];
|
||||||
|
}, $data['order_total']));
|
||||||
|
|
||||||
|
if ($totalDiscount > 0 && false !== $keyRetailCrmDiscount) {
|
||||||
|
$data['order_total'][$keyRetailCrmDiscount]['value'] = -$totalDiscount;
|
||||||
|
} elseif ($totalDiscount <= 0 && false !== $keyRetailCrmDiscount) {
|
||||||
|
unset($data['order_total'][$keyRetailCrmDiscount]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data opencart order
|
* @param array $data opencart order
|
||||||
* @param array $order retailCRM order
|
* @param array $order RetailCRM order
|
||||||
*/
|
*/
|
||||||
public function handleCustomFields(&$data, $order) {
|
public function handleCustomFields(&$data, $order) {
|
||||||
$settings = $this->settings_manager->getSetting('custom_field');
|
$settings = $this->settings_manager->getSetting('custom_field');
|
||||||
|
|
|
@ -124,6 +124,7 @@ class DataRepository extends \retailcrm\Base {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getZoneByName($name) {
|
public function getZoneByName($name) {
|
||||||
|
$name = $this->db->escape($name);
|
||||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE name = '" . $name . "'");
|
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE name = '" . $name . "'");
|
||||||
|
|
||||||
return $query->row;
|
return $query->row;
|
||||||
|
|
|
@ -163,12 +163,9 @@ class CorporateCustomer {
|
||||||
if ($address_response && $address_response->isSuccessful()) {
|
if ($address_response && $address_response->isSuccessful()) {
|
||||||
$company = CorporateCustomerBuilder::create(false)
|
$company = CorporateCustomerBuilder::create(false)
|
||||||
->setCompany($order_data['payment_company'])
|
->setCompany($order_data['payment_company'])
|
||||||
|
->setCompanyAddressId($address_response['id'])
|
||||||
->buildCompany($order_data);
|
->buildCompany($order_data);
|
||||||
|
|
||||||
$company['address'] = array(
|
|
||||||
'id' => $address_response['id']
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->api->customersCorporateCompaniesCreate($corp_client_id, $company, 'id');
|
$this->api->customersCorporateCompaniesCreate($corp_client_id, $company, 'id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,11 +177,14 @@ class CorporateCustomer {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function updateOrCreateAddress($order_data, $corp_client) {
|
private function updateOrCreateAddress($order_data, $corp_client) {
|
||||||
|
$address_id = null;
|
||||||
$addresses_response = $this->api->customersCorporateAddresses($corp_client['id'], array(), null, null, 'id');
|
$addresses_response = $this->api->customersCorporateAddresses($corp_client['id'], array(), null, null, 'id');
|
||||||
$corp_address = CorporateCustomerBuilder::create(false)->buildAddress($order_data);
|
$corp_address = CorporateCustomerBuilder::create(false)->buildAddress($order_data);
|
||||||
|
|
||||||
if ($addresses_response && $addresses_response->isSuccessful() && !empty($addresses_response['addresses'])) {
|
if ($addresses_response && $addresses_response->isSuccessful() && !empty($addresses_response['addresses'])) {
|
||||||
foreach ($addresses_response['addresses'] as $address) {
|
foreach ($addresses_response['addresses'] as $address) {
|
||||||
if (Utils::addressEquals($corp_address, $address)) {
|
if (Utils::addressEquals($corp_address, $address)) {
|
||||||
|
$address_id = $address['id'];
|
||||||
$exist_address = $address;
|
$exist_address = $address;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -193,25 +193,35 @@ class CorporateCustomer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($exist_address)) {
|
if (!isset($exist_address)) {
|
||||||
$this->api->customersCorporateAddressesCreate(
|
$response = $this->api->customersCorporateAddressesCreate(
|
||||||
$corp_client['id'],
|
$corp_client['id'],
|
||||||
$corp_address,
|
$corp_address,
|
||||||
'id'
|
'id'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($response && $response->isSuccessful() && isset($response['id'])) {
|
||||||
|
$address_id = $response['id'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($corp_client['mainCompany'])) {
|
$company = CorporateCustomerBuilder::create(false)
|
||||||
$company = CorporateCustomerBuilder::create(false)
|
->setCompany($order_data['payment_company'])
|
||||||
->setCompany($order_data['payment_company'])
|
->setCompanyAddressId($address_id)
|
||||||
->buildCompany($order_data);
|
->buildCompany($order_data);
|
||||||
|
$companies = $this->api->customersCorporateCompanies($corp_client['id'], array(), null, null, 'id');
|
||||||
|
|
||||||
$this->api->customersCorporateCompaniesEdit(
|
if ($companies && $companies->isSuccessful() && !empty($companies['companies'])) {
|
||||||
$corp_client['id'],
|
foreach ($companies['companies'] as $crm_company) {
|
||||||
$corp_client['mainCompany']['id'],
|
if ($crm_company['name'] === $order_data['payment_company']) {
|
||||||
$company,
|
$this->api->customersCorporateCompaniesEdit(
|
||||||
'id',
|
$corp_client['id'],
|
||||||
'id'
|
$crm_company['id'],
|
||||||
);
|
$company,
|
||||||
|
'id',
|
||||||
|
'id'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
namespace retailcrm\service;
|
namespace retailcrm\service;
|
||||||
|
|
||||||
class CorporateCustomerBuilder {
|
class CorporateCustomerBuilder {
|
||||||
|
private $is_main_company = false;
|
||||||
|
private $company_address_id = null;
|
||||||
private $data = array();
|
private $data = array();
|
||||||
private $company;
|
private $company;
|
||||||
|
|
||||||
|
@ -36,6 +38,28 @@ class CorporateCustomerBuilder {
|
||||||
return $this->data;
|
return $this->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $isMainCompany
|
||||||
|
*
|
||||||
|
* @return CorporateCustomerBuilder
|
||||||
|
*/
|
||||||
|
public function setIsMainCompany($isMainCompany)
|
||||||
|
{
|
||||||
|
$this->is_main_company = $isMainCompany;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $companyAddressId
|
||||||
|
*
|
||||||
|
* @return CorporateCustomerBuilder
|
||||||
|
*/
|
||||||
|
public function setCompanyAddressId($companyAddressId)
|
||||||
|
{
|
||||||
|
$this->company_address_id = $companyAddressId;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setCompany($company) {
|
public function setCompany($company) {
|
||||||
$this->company = $company;
|
$this->company = $company;
|
||||||
|
|
||||||
|
@ -83,14 +107,23 @@ class CorporateCustomerBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildCompany($data) {
|
public function buildCompany($data) {
|
||||||
return array(
|
$company = array(
|
||||||
'isMain' => true,
|
|
||||||
'name' => $this->company,
|
'name' => $this->company,
|
||||||
'contragent' => array(
|
'contragent' => array(
|
||||||
'legalAddress' => $this->buildLegalAddress($data),
|
'legalAddress' => $this->buildLegalAddress($data),
|
||||||
'contragentType' => 'legal-entity',
|
'contragentType' => 'legal-entity',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($this->is_main_company) {
|
||||||
|
$company['isMain'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $this->company_address_id) {
|
||||||
|
$company['address'] = array('id' => $this->company_address_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $company;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addCompany($data) {
|
public function addCompany($data) {
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
|
|
||||||
namespace retailcrm\service;
|
namespace retailcrm\service;
|
||||||
|
|
||||||
/**
|
|
||||||
* Class CustomerManager
|
|
||||||
*/
|
|
||||||
class CustomerManager {
|
class CustomerManager {
|
||||||
protected $api;
|
protected $api;
|
||||||
protected $customer_converter;
|
protected $customer_converter;
|
||||||
|
@ -15,7 +12,7 @@ class CustomerManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createCustomer($customer_data, $address) {
|
public function createCustomer($customer_data, $address) {
|
||||||
$customer = $this->prepareCustomer($customer_data, $address);
|
$customer = $this->prepareCustomer($customer_data, $address, !empty($customer_data['newsletter']));
|
||||||
|
|
||||||
$this->api->customersCreate($customer);
|
$this->api->customersCreate($customer);
|
||||||
}
|
}
|
||||||
|
@ -26,13 +23,22 @@ class CustomerManager {
|
||||||
$this->api->customersEdit($customer);
|
$this->api->customersEdit($customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function editCustomerNewsLetter($customer_data) {
|
||||||
|
$this->api->customersEdit(
|
||||||
|
[
|
||||||
|
'externalId' => $customer_data['customer_id'],
|
||||||
|
'subscribed' => !empty($customer_data['newsletter']),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function uploadCustomers($customers) {
|
public function uploadCustomers($customers) {
|
||||||
$this->api->customersUpload($customers);
|
$this->api->customersUpload($customers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prepareCustomer($customer_data, $address) {
|
public function prepareCustomer($customer_data, $address, $isSubscribed = null) {
|
||||||
return $this->customer_converter
|
return $this->customer_converter
|
||||||
->initCustomerData($customer_data, $address)
|
->initCustomerData($customer_data, $address, $isSubscribed)
|
||||||
->setCustomerData()
|
->setCustomerData()
|
||||||
->setAddress()
|
->setAddress()
|
||||||
->setCustomFields()
|
->setCustomFields()
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
|
|
||||||
namespace retailcrm\service;
|
namespace retailcrm\service;
|
||||||
|
|
||||||
/**
|
|
||||||
* Class OrderManager
|
|
||||||
*/
|
|
||||||
class OrderManager {
|
class OrderManager {
|
||||||
protected $api;
|
protected $api;
|
||||||
protected $customer_manager;
|
protected $customer_manager;
|
||||||
|
@ -42,7 +39,10 @@ class OrderManager {
|
||||||
public function createOrder($order_data, $order_products, $order_totals) {
|
public function createOrder($order_data, $order_products, $order_totals) {
|
||||||
$order = $this->prepareOrder($order_data, $order_products, $order_totals);
|
$order = $this->prepareOrder($order_data, $order_products, $order_totals);
|
||||||
|
|
||||||
if (!isset($order['customer'])) {
|
if (!isset($order['customer'])
|
||||||
|
|| (isset($order['customer']['externalId'])
|
||||||
|
&& !$this->checkExistCustomer($order['customer']['externalId']))
|
||||||
|
) {
|
||||||
$customer = $this->customer_manager->getCustomerForOrder($order_data);
|
$customer = $this->customer_manager->getCustomerForOrder($order_data);
|
||||||
if (!empty($customer)) {
|
if (!empty($customer)) {
|
||||||
$order['customer'] = $customer;
|
$order['customer'] = $customer;
|
||||||
|
@ -155,7 +155,7 @@ class OrderManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($order_info['payments'] as $payment_data) {
|
foreach ($order_info['payments'] as $payment_data) {
|
||||||
if (isset($payment_data['externalId']) && $payment_data['externalId'] == $orderId) {
|
if (isset($payment_data['externalId'])) {
|
||||||
$payment = $payment_data;
|
$payment = $payment_data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,4 +170,15 @@ class OrderManager {
|
||||||
$this->api->ordersPaymentEdit($order_payment);
|
$this->api->ordersPaymentEdit($order_payment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $customerExternalId Customer's external id
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function checkExistCustomer($customerExternalId) {
|
||||||
|
$result = $this->api->customersGet($customerExternalId);
|
||||||
|
|
||||||
|
return $result && $result->isSuccessful() && $result->offsetExists('customer');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ namespace retailcrm\service;
|
||||||
|
|
||||||
class RetailcrmCustomerConverter {
|
class RetailcrmCustomerConverter {
|
||||||
protected $data;
|
protected $data;
|
||||||
protected $customer_data = array();
|
protected $customer_data = [];
|
||||||
protected $address = array();
|
protected $address = [];
|
||||||
|
protected $isSubscribed;
|
||||||
protected $settingsManager;
|
protected $settingsManager;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
@ -19,10 +19,11 @@ class RetailcrmCustomerConverter {
|
||||||
return $this->data;
|
return $this->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initCustomerData($customer_data, $address) {
|
public function initCustomerData($customer_data, $address, $isSubscribed) {
|
||||||
$this->data = array();
|
$this->data = [];
|
||||||
$this->customer_data = $customer_data;
|
$this->customer_data = $customer_data;
|
||||||
$this->address = $address;
|
$this->address = $address;
|
||||||
|
$this->isSubscribed = $isSubscribed;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -34,12 +35,12 @@ class RetailcrmCustomerConverter {
|
||||||
$this->data['email'] = $this->customer_data['email'];
|
$this->data['email'] = $this->customer_data['email'];
|
||||||
$this->data['createdAt'] = $this->customer_data['date_added'];
|
$this->data['createdAt'] = $this->customer_data['date_added'];
|
||||||
|
|
||||||
|
if ($this->isSubscribed !== null) {
|
||||||
|
$this->data['subscribed'] = $this->isSubscribed;
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($this->customer_data['telephone'])) {
|
if (!empty($this->customer_data['telephone'])) {
|
||||||
$this->data['phones'] = array(
|
$this->data['phones'] = [['number' => $this->customer_data['telephone']]];
|
||||||
array(
|
|
||||||
'number' => $this->customer_data['telephone']
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -47,13 +48,13 @@ class RetailcrmCustomerConverter {
|
||||||
|
|
||||||
public function setAddress() {
|
public function setAddress() {
|
||||||
if (!empty($this->address)) {
|
if (!empty($this->address)) {
|
||||||
$this->data['address'] = array(
|
$this->data['address'] = [
|
||||||
'index' => $this->address['postcode'],
|
'index' => $this->address['postcode'],
|
||||||
'countryIso' => $this->address['iso_code_2'],
|
'countryIso' => $this->address['iso_code_2'],
|
||||||
'region' => $this->address['zone'],
|
'region' => $this->address['zone'],
|
||||||
'city' => $this->address['city'],
|
'city' => $this->address['city'],
|
||||||
'text' => $this->address['address_1'] . ' ' . $this->address['address_2']
|
'text' => $this->address['address_1'] . ' ' . $this->address['address_2']
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -43,12 +43,14 @@ class RetailcrmOrderConverter {
|
||||||
$this->data['countryIso'] = $this->order_data['shipping_iso_code_2'];
|
$this->data['countryIso'] = $this->order_data['shipping_iso_code_2'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->settingsManager->getSetting('order_number')
|
if ($this->settingsManager->getSetting('order_number') == 1) {
|
||||||
&& $this->settingsManager->getSetting('order_number') == 1
|
|
||||||
) {
|
|
||||||
$this->data['number'] = $this->order_data['order_id'];
|
$this->data['number'] = $this->order_data['order_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->settingsManager->getSetting('summ_around') == 1) {
|
||||||
|
$this->data['applyRound'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
$this->data['externalId'] = $this->order_data['order_id'];
|
$this->data['externalId'] = $this->order_data['order_id'];
|
||||||
$this->data['firstName'] = $this->order_data['shipping_firstname'];
|
$this->data['firstName'] = $this->order_data['shipping_firstname'];
|
||||||
$this->data['lastName'] = $this->order_data['shipping_lastname'];
|
$this->data['lastName'] = $this->order_data['shipping_lastname'];
|
||||||
|
@ -76,19 +78,29 @@ class RetailcrmOrderConverter {
|
||||||
|
|
||||||
public function setDiscount() {
|
public function setDiscount() {
|
||||||
$discount = 0;
|
$discount = 0;
|
||||||
|
$totalCoupon = $this->getTotal('coupon');
|
||||||
|
$totalReward = $this->getTotal('reward');
|
||||||
|
$totalVoucher = $this->getTotal('voucher');
|
||||||
|
$retailcrmDiscount = $this->getTotal(\retailcrm\Retailcrm::RETAILCRM_DISCOUNT);
|
||||||
|
|
||||||
if (!empty($this->getTotal('coupon'))) {
|
if (!empty($totalCoupon)) {
|
||||||
$discount += abs($this->getTotal('coupon'));
|
$discount += abs($totalCoupon);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($this->getTotal('reward'))) {
|
if (!empty($totalReward)) {
|
||||||
$discount += abs($this->getTotal('reward'));
|
$discount += abs($totalReward);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($discount > 0) {
|
if (!empty($totalVoucher)) {
|
||||||
$order['discountManualAmount'] = $discount;
|
$discount += abs($totalVoucher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($retailcrmDiscount)) {
|
||||||
|
$discount += abs($retailcrmDiscount);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->data['discountManualAmount'] = $discount;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,10 +111,15 @@ class RetailcrmOrderConverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
$payment = array(
|
$payment = array(
|
||||||
'externalId' => sprintf("opencart_%d", $this->order_data['order_id']),
|
'externalId' => uniqid($this->order_data['order_id'] . "-"),
|
||||||
'amount' => $this->getTotal('total')
|
'amount' => $this->getTotal('total')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($this->settingsManager->getSetting('sum_payment') &&
|
||||||
|
$this->settingsManager->getSetting('sum_payment') == 1) {
|
||||||
|
unset($payment['amount']);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($payment_type)) {
|
if (!empty($payment_type)) {
|
||||||
$payment['type'] = $payment_type;
|
$payment['type'] = $payment_type;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +130,9 @@ class RetailcrmOrderConverter {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->data['payments'][] = $payment;
|
if (!empty($payment['type'])) {
|
||||||
|
$this->data['payments'][] = $payment;
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -165,8 +184,10 @@ class RetailcrmOrderConverter {
|
||||||
$this->data['delivery']['code'] = $delivery_code;
|
$this->data['delivery']['code'] = $delivery_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($this->getTotal('shipping'))) {
|
$totalShipping = $this->getTotal('shipping');
|
||||||
$this->data['delivery']['cost'] = $this->getTotal('shipping');
|
|
||||||
|
if (!empty($totalShipping)) {
|
||||||
|
$this->data['delivery']['cost'] = $totalShipping;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -223,19 +244,29 @@ class RetailcrmOrderConverter {
|
||||||
'quantity' => $product['quantity']
|
'quantity' => $product['quantity']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$date = date('Y-m-d');
|
||||||
|
$always = '0000-00-00';
|
||||||
$specials = $this->productsRepository->getProductSpecials($product['product_id']);
|
$specials = $this->productsRepository->getProductSpecials($product['product_id']);
|
||||||
|
|
||||||
if (!empty($specials)) {
|
if (!empty($specials)) {
|
||||||
$customer = $this->customerRepository->getCustomer($this->order_data['customer_id']);
|
$customer = $this->customerRepository->getCustomer($this->order_data['customer_id']);
|
||||||
|
|
||||||
foreach ($specials as $special) {
|
foreach ($specials as $special) {
|
||||||
if (empty($customer['customer_group_id'])) {
|
if (($special['date_start'] == $always && $special['date_end'] == $always)
|
||||||
continue;
|
|| ($special['date_start'] <= $date && $special['date_end'] >= $date)
|
||||||
}
|
) {
|
||||||
|
if ((isset($priority) && $priority > $special['priority'])
|
||||||
|
|| !isset($priority)) {
|
||||||
|
if (empty($customer['customer_group_id'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$specialSetting = $this->settingsManager->getSetting('special_' . $customer['customer_group_id']);
|
$specialSetting = $this->settingsManager->getSetting('special_' . $customer['customer_group_id']);
|
||||||
if ($special['customer_group_id'] == $customer['customer_group_id'] && !empty($specialSetting)) {
|
if ($special['customer_group_id'] == $customer['customer_group_id'] && !empty($specialSetting)) {
|
||||||
$item['priceType']['code'] = $specialSetting;
|
$item['priceType']['code'] = $specialSetting;
|
||||||
|
$priority = $special['priority'];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,10 @@ class SettingsManager extends \retailcrm\Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSetting($key) {
|
public function getSetting($key) {
|
||||||
if (!empty($this->getSettings()[$this->retailcrm->getModuleTitle() . '_' . $key])) {
|
$settings = $this->getSettings();
|
||||||
return $this->getSettings()[$this->retailcrm->getModuleTitle() . '_' . $key];
|
|
||||||
|
if (!empty($settings[$this->retailcrm->getModuleTitle() . '_' . $key])) {
|
||||||
|
return $settings[$this->retailcrm->getModuleTitle() . '_' . $key];
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
<field id="cumulative_discount" group="customer">cumulativeDiscount</field>
|
<field id="cumulative_discount" group="customer">cumulativeDiscount</field>
|
||||||
<field id="personal_discount" group="customer">personalDiscount</field>
|
<field id="personal_discount" group="customer">personalDiscount</field>
|
||||||
<field id="discount_card_number" group="customer">discountCardNumber</field>
|
<field id="discount_card_number" group="customer">discountCardNumber</field>
|
||||||
|
<field id="email_marketing_unsubscribed_at" group="customer">emailMarketingUnsubscribedAt</field>
|
||||||
|
|
||||||
<field id="address.index" group="customerAddress">index</field>
|
<field id="address.index" group="customerAddress">index</field>
|
||||||
<field id="address.country" group="customerAddress">country</field>
|
<field id="address.country" group="customerAddress">country</field>
|
||||||
|
|
|
@ -10,14 +10,21 @@ use retailcrm\factory\OrderConverterFactory;
|
||||||
use retailcrm\factory\CustomerConverterFactory;
|
use retailcrm\factory\CustomerConverterFactory;
|
||||||
use retailcrm\service\SettingsManager;
|
use retailcrm\service\SettingsManager;
|
||||||
|
|
||||||
require_once 'bootstrap.php';
|
require_once DIR_SYSTEM . 'library/retailcrm/bootstrap.php';
|
||||||
|
|
||||||
class Retailcrm {
|
class Retailcrm {
|
||||||
|
|
||||||
|
const RETAILCRM_DISCOUNT = 'retailcrm_discount';
|
||||||
|
const RETAILCRM_DISCOUNT_SORT_ORDER = 8;
|
||||||
|
const VERSION_MODULE = '4.1.19';
|
||||||
|
|
||||||
protected $registry;
|
protected $registry;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
public static $history_run = false;
|
public static $history_run = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(\Registry $registry) {
|
public function __construct(\Registry $registry) {
|
||||||
$this->registry = $registry;
|
$this->registry = $registry;
|
||||||
|
|
||||||
|
@ -52,12 +59,11 @@ class Retailcrm {
|
||||||
*
|
*
|
||||||
* @param string $apiUrl (default = null)
|
* @param string $apiUrl (default = null)
|
||||||
* @param string $apiKey (default = null)
|
* @param string $apiKey (default = null)
|
||||||
* @param string $apiVersion (default = null)
|
|
||||||
*
|
*
|
||||||
* @return mixed object | boolean
|
* @return mixed object | boolean
|
||||||
*/
|
*/
|
||||||
public function getApiClient($apiUrl = null, $apiKey = null, $apiVersion = null) {
|
public function getApiClient($apiUrl = null, $apiKey = null) {
|
||||||
if (!$this->registry->has(\RetailcrmProxy::class)) {
|
if (!$this->registry->has('RetailcrmProxy')) {
|
||||||
$setting = $this->model_setting_setting->getSetting($this->getModuleTitle());
|
$setting = $this->model_setting_setting->getSetting($this->getModuleTitle());
|
||||||
|
|
||||||
if ($apiUrl === null && $apiKey === null) {
|
if ($apiUrl === null && $apiKey === null) {
|
||||||
|
@ -72,12 +78,12 @@ class Retailcrm {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->registry->set(
|
$this->registry->set(
|
||||||
\RetailcrmProxy::class,
|
'RetailcrmProxy',
|
||||||
new \RetailcrmProxy($apiUrl, $apiKey)
|
new \RetailcrmProxy($apiUrl, $apiKey)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->registry->get(\RetailcrmProxy::class);
|
return $this->registry->get('RetailcrmProxy');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,12 +128,12 @@ class Retailcrm {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOffers($product) {
|
public function getOffers($product) {
|
||||||
// Формируем офферы отнсительно доступных опций
|
// Build offers by available options
|
||||||
$options = $this->model_catalog_product->getProductOptions($product['product_id']);
|
$options = $this->model_catalog_product->getProductOptions($product['product_id']);
|
||||||
$offerOptions = array('select', 'radio');
|
$offerOptions = array('select', 'radio');
|
||||||
$requiredOptions = array();
|
$requiredOptions = array();
|
||||||
$notRequiredOptions = array();
|
$notRequiredOptions = array();
|
||||||
// Оставляем опции связанные с вариациями товаров, сортируем по параметру обязательный или нет
|
// Handle & sort mandatory options
|
||||||
foreach($options as $option) {
|
foreach($options as $option) {
|
||||||
if(in_array($option['type'], $offerOptions)) {
|
if(in_array($option['type'], $offerOptions)) {
|
||||||
if($option['required']) {
|
if($option['required']) {
|
||||||
|
@ -139,14 +145,14 @@ class Retailcrm {
|
||||||
}
|
}
|
||||||
|
|
||||||
$offers = array();
|
$offers = array();
|
||||||
// Сначала совмещаем все обязательные опции
|
|
||||||
foreach($requiredOptions as $requiredOption) {
|
foreach($requiredOptions as $requiredOption) {
|
||||||
// Если первая итерация
|
|
||||||
if(empty($offers)) {
|
if(empty($offers)) {
|
||||||
foreach($requiredOption['product_option_value'] as $optionValue) {
|
foreach($requiredOption['product_option_value'] as $optionValue) {
|
||||||
$offers[$requiredOption['product_option_id'].':'.$requiredOption['option_id'].'-'.$optionValue['option_value_id']] = array(
|
$offers[$requiredOption['product_option_id'].':'.$requiredOption['option_id'].'-'.$optionValue['option_value_id']] = array(
|
||||||
'price' => (float)$this->getOptionPrice($optionValue),
|
'price' => (float)$this->getOptionPrice($optionValue),
|
||||||
'qty' => $optionValue['quantity']
|
'qty' => $optionValue['quantity'],
|
||||||
|
'weight' => round($this->getWeightOption($optionValue), 3)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -156,22 +162,22 @@ class Retailcrm {
|
||||||
$offers[$optionKey.'_'.$requiredOption['product_option_id'].':'.$requiredOption['option_id'].'-'.$optionValue['option_value_id']] = array(
|
$offers[$optionKey.'_'.$requiredOption['product_option_id'].':'.$requiredOption['option_id'].'-'.$optionValue['option_value_id']] = array(
|
||||||
'price' => $optionAttr['price'] + (float)$this->getOptionPrice($optionValue),
|
'price' => $optionAttr['price'] + (float)$this->getOptionPrice($optionValue),
|
||||||
'qty' => ($optionAttr['qty'] > $optionValue['quantity']) ?
|
'qty' => ($optionAttr['qty'] > $optionValue['quantity']) ?
|
||||||
$optionValue['quantity'] : $optionAttr['qty']
|
$optionValue['quantity'] : $optionAttr['qty'],
|
||||||
|
'weight' => round($optionAttr['weight'] + $this->getWeightOption($optionValue), 3)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Совмещаем или добавляем необязательные опции, учитывая тот факт что обязательных опций может и не быть.
|
|
||||||
foreach($notRequiredOptions as $notRequiredOption) {
|
foreach($notRequiredOptions as $notRequiredOption) {
|
||||||
// Если обязательных опцией не оказалось и первая итерация
|
|
||||||
if(empty($offers)) {
|
if(empty($offers)) {
|
||||||
$offers['0:0-0'] = 0; // В случае работы с необязательными опциями мы должны учитывать товарное предложение без опций, поэтому создадим "пустую" опцию
|
$offers['0:0-0'] = 0; // Add empty option for mandatory data
|
||||||
foreach($notRequiredOption['product_option_value'] as $optionValue) {
|
foreach($notRequiredOption['product_option_value'] as $optionValue) {
|
||||||
$offers[$notRequiredOption['product_option_id'].':'.$notRequiredOption['option_id'].'-'.$optionValue['option_value_id']] = array(
|
$offers[$notRequiredOption['product_option_id'].':'.$notRequiredOption['option_id'].'-'.$optionValue['option_value_id']] = array(
|
||||||
'price' => (float)$this->getOptionPrice($optionValue),
|
'price' => (float)$this->getOptionPrice($optionValue),
|
||||||
'qty' => $optionValue['quantity']
|
'qty' => $optionValue['quantity'],
|
||||||
|
'weight' => round($this->getWeightOption($optionValue), 3)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -180,7 +186,8 @@ class Retailcrm {
|
||||||
$offers[$optionKey.'_'.$notRequiredOption['product_option_id'].':'.$notRequiredOption['option_id'].'-'.$optionValue['option_value_id']] = array(
|
$offers[$optionKey.'_'.$notRequiredOption['product_option_id'].':'.$notRequiredOption['option_id'].'-'.$optionValue['option_value_id']] = array(
|
||||||
'price' => $optionAttr['price'] + (float)$this->getOptionPrice($optionValue),
|
'price' => $optionAttr['price'] + (float)$this->getOptionPrice($optionValue),
|
||||||
'qty' => ($optionAttr['qty'] > $optionValue['quantity']) ?
|
'qty' => ($optionAttr['qty'] > $optionValue['quantity']) ?
|
||||||
$optionValue['quantity'] : $optionAttr['qty']
|
$optionValue['quantity'] : $optionAttr['qty'],
|
||||||
|
'weight' => round($optionAttr['weight'] + $this->getWeightOption($optionValue), 3)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,6 +201,19 @@ class Retailcrm {
|
||||||
return $offers;
|
return $offers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $option
|
||||||
|
*
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
private function getWeightOption($option) {
|
||||||
|
if ($option['weight_prefix'] === '-') {
|
||||||
|
return $option['weight'] * -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $option['weight'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $optionValue
|
* @param array $optionValue
|
||||||
* @return float|int|mixed
|
* @return float|int|mixed
|
||||||
|
@ -223,6 +243,15 @@ class Retailcrm {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function useServicesForIcml()
|
||||||
|
{
|
||||||
|
$this->load->model('setting/setting');
|
||||||
|
|
||||||
|
$setting = $this->model_setting_setting->getSetting($this->getModuleTitle());
|
||||||
|
|
||||||
|
return $setting['module_retailcrm_icml_service_enabled'] ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class TestCase extends OpenCartTest {
|
|
||||||
public function setUp() {
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
$this->load->library('retailcrm/retailcrm');
|
|
||||||
|
|
||||||
$this->setSetting(
|
|
||||||
$this->retailcrm->getModuleTitle(),
|
|
||||||
array(
|
|
||||||
$this->retailcrm->getModuleTitle() . '_apiversion' => 'v5',
|
|
||||||
$this->retailcrm->getModuleTitle() . '_order_number' => 1,
|
|
||||||
$this->retailcrm->getModuleTitle() . '_status' => array(
|
|
||||||
1 => 'new'
|
|
||||||
),
|
|
||||||
$this->retailcrm->getModuleTitle() . '_delivery' => array(
|
|
||||||
'flat.flat' => 'flat'
|
|
||||||
),
|
|
||||||
$this->retailcrm->getModuleTitle() . '_payment' => array(
|
|
||||||
'cod' => 'cod'
|
|
||||||
),
|
|
||||||
$this->retailcrm->getModuleTitle() . '_special_1' => 'special1',
|
|
||||||
$this->retailcrm->getModuleTitle() . '_special_2' => 'special2',
|
|
||||||
$this->retailcrm->getModuleTitle() . '_special_3' => 'special3',
|
|
||||||
$this->retailcrm->getModuleTitle() . '_collector' => array(
|
|
||||||
'site_key' => 'RC-XXXXXXXXXX-X',
|
|
||||||
'custom_form' => 1,
|
|
||||||
'custom' => array(
|
|
||||||
'name' => 'Name',
|
|
||||||
'email' => 'Email',
|
|
||||||
'phone' => 'Phone',
|
|
||||||
),
|
|
||||||
'form_capture' => 1,
|
|
||||||
'period' => 1
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setSetting($code, $data, $store_id = 0) {
|
|
||||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "setting` WHERE store_id = '" . (int)$store_id . "' AND `code` = '" . $this->db->escape($code) . "'");
|
|
||||||
|
|
||||||
foreach ($data as $key => $value) {
|
|
||||||
if (substr($key, 0, strlen($code)) == $code) {
|
|
||||||
if (!is_array($value)) {
|
|
||||||
$this->db->query("INSERT INTO " . DB_PREFIX . "setting SET store_id = '" . (int)$store_id . "', `code` = '" . $this->db->escape($code) . "', `key` = '" . $this->db->escape($key) . "', `value` = '" . $this->db->escape($value) . "'");
|
|
||||||
} else {
|
|
||||||
$this->db->query("INSERT INTO " . DB_PREFIX . "setting SET store_id = '" . (int)$store_id . "', `code` = '" . $this->db->escape($code) . "', `key` = '" . $this->db->escape($key) . "', `value` = '" . $this->db->escape(json_encode($value, true)) . "', serialized = '1'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,6 +7,16 @@ class RoboFile extends \Robo\Tasks
|
||||||
use \Robo\Task\Development\loadTasks;
|
use \Robo\Task\Development\loadTasks;
|
||||||
use \Robo\Common\TaskIO;
|
use \Robo\Common\TaskIO;
|
||||||
|
|
||||||
|
const OPENCART_DOWNLOAD_URL = [
|
||||||
|
'3.0.1.2' => 'https://github.com/opencart/opencart/releases/download/3.0.1.2/3.0.1.2-opencart.zip',
|
||||||
|
'3.0.2.0' => 'https://github.com/opencart/opencart/releases/download/3.0.2.0/3.0.2.0-OpenCart.zip',
|
||||||
|
'3.0.3.4' => 'https://github.com/opencart/opencart/releases/download/3.0.3.4/opencart-3.0.3.4-core-pre.zip'
|
||||||
|
];
|
||||||
|
|
||||||
|
const OPENCART_ROOT_DIR = [
|
||||||
|
'3.0.3.4' => 'opencart-3.0.3.4/upload'
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
@ -67,19 +77,21 @@ class RoboFile extends \Robo\Tasks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function opencartSetup()
|
public function opencartInstall()
|
||||||
{
|
{
|
||||||
$startUp = getenv('TEST_SUITE') === '2.3'
|
$startUp = 'admin/controller/startup/test_startup.php';
|
||||||
? 'catalog/controller/startup/test_startup.php'
|
$startUpTo = 'admin/controller/startup/test_startup.php';
|
||||||
: 'admin/controller/startup/test_startup.php';
|
$version = getenv('OPENCART');
|
||||||
$startUpTo = getenv('TEST_SUITE') === '2.3'
|
$ocZip = sprintf('/tmp/opencart-%s.zip', $version);
|
||||||
? 'catalog/controller/startup/test_startup.php'
|
|
||||||
: 'admin/controller/startup/test_startup.php';
|
|
||||||
|
|
||||||
$this->taskDeleteDir($this->root_dir . 'www')->run();
|
$this->taskDeleteDir($this->root_dir . 'www')->run();
|
||||||
|
|
||||||
|
file_put_contents($ocZip, file_get_contents($this->getOpencartDownloadUrl($version)));
|
||||||
|
|
||||||
|
$this->_exec(sprintf('unzip %s -d /tmp/opencart', $ocZip));
|
||||||
$this->taskFileSystemStack()
|
$this->taskFileSystemStack()
|
||||||
->mirror(
|
->mirror(
|
||||||
$this->root_dir . 'vendor/opencart/opencart/upload',
|
$this->getOpencartRootDir($version),
|
||||||
$this->root_dir . 'www'
|
$this->root_dir . 'www'
|
||||||
)
|
)
|
||||||
->copy(
|
->copy(
|
||||||
|
@ -93,13 +105,31 @@ class RoboFile extends \Robo\Tasks
|
||||||
->chmod($this->root_dir . 'www', 0777, 0000, true)
|
->chmod($this->root_dir . 'www', 0777, 0000, true)
|
||||||
->run();
|
->run();
|
||||||
|
|
||||||
if (getenv('TEST_SUITE') === '3.0') {
|
if (getenv('TEST_SUITE') === '3') {
|
||||||
$this->taskFileSystemStack()->copy(
|
$this->taskFileSystemStack()->copy(
|
||||||
$this->root_dir . 'vendor/beyondit/opencart-test-suite/src/upload/system/library/session/test.php',
|
$this->root_dir . 'vendor/beyondit/opencart-test-suite/src/upload/system/library/session/test.php',
|
||||||
$this->root_dir . 'www/system/library/session/test.php'
|
$this->root_dir . 'www/system/library/session/test.php'
|
||||||
)->run();
|
)->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Openbay was removed in 3.0.3.6
|
||||||
|
// Unfortunately, those configs from test suite still require it.
|
||||||
|
if (
|
||||||
|
'3.0.3.4' === getenv('OPENCART') ||
|
||||||
|
version_compare(getenv('OPENCART'), '3.0.3.6', '>=')
|
||||||
|
) {
|
||||||
|
$testConfigFile = $this->root_dir . 'www/system/config/test-config.php';
|
||||||
|
$testStartupFile = $this->root_dir . 'www/' . $startUpTo;
|
||||||
|
$testConfig = file_get_contents($testConfigFile);
|
||||||
|
$testStartup = file_get_contents($testStartupFile);
|
||||||
|
|
||||||
|
$testConfig = str_ireplace("'openbay'", '', $testConfig);
|
||||||
|
$testStartup = str_ireplace('$this->registry->set(\'openbay\', new Openbay($this->registry));', '', $testStartup);
|
||||||
|
|
||||||
|
file_put_contents($testConfigFile, $testConfig);
|
||||||
|
file_put_contents($testStartupFile, $testStartup);
|
||||||
|
}
|
||||||
|
|
||||||
// Create new database, drop if exists already
|
// Create new database, drop if exists already
|
||||||
try {
|
try {
|
||||||
$conn = new PDO("mysql:host=".$this->opencart_config['db_hostname'], $this->opencart_config['db_username'], $this->opencart_config['db_password']);
|
$conn = new PDO("mysql:host=".$this->opencart_config['db_hostname'], $this->opencart_config['db_username'], $this->opencart_config['db_password']);
|
||||||
|
@ -109,7 +139,8 @@ class RoboFile extends \Robo\Tasks
|
||||||
}
|
}
|
||||||
catch(PDOException $e)
|
catch(PDOException $e)
|
||||||
{
|
{
|
||||||
$this->printTaskError("<error> Could not connect ot database...");
|
$this->printTaskError($e->getMessage());
|
||||||
|
$this->printTaskError("<error> Could not connect to database...");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version_compare(getenv('OPENCART'), '3.0.2.0', '<=')) {
|
if (version_compare(getenv('OPENCART'), '3.0.2.0', '<=')) {
|
||||||
|
@ -191,13 +222,31 @@ EOF;
|
||||||
$zip->close();
|
$zip->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getOpencartDownloadUrl(string $version): string
|
||||||
|
{
|
||||||
|
if (version_compare($version, '3.0.1.1', '<=')) {
|
||||||
|
return sprintf('https://github.com/opencart/opencart/releases/download/%s/%s-compiled.zip', $version, $version);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists($version, self::OPENCART_DOWNLOAD_URL)) {
|
||||||
|
return self::OPENCART_DOWNLOAD_URL[$version];
|
||||||
|
}
|
||||||
|
|
||||||
|
return sprintf('https://github.com/opencart/opencart/releases/download/%s/opencart-%s.zip', $version, $version);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getOpencartRootDir(string $version): string
|
||||||
|
{
|
||||||
|
if (array_key_exists($version, self::OPENCART_ROOT_DIR)) {
|
||||||
|
return '/tmp/opencart/' . self::OPENCART_ROOT_DIR[$version];
|
||||||
|
}
|
||||||
|
|
||||||
|
return '/tmp/opencart/upload';
|
||||||
|
}
|
||||||
|
|
||||||
private function restoreSampleData($conn)
|
private function restoreSampleData($conn)
|
||||||
{
|
{
|
||||||
if (getenv('TEST_SUITE') === '2.3') {
|
$sql = file_get_contents($this->root_dir . 'tests/opencart_sample_data_3.sql');
|
||||||
$sql = file_get_contents($this->root_dir . 'tests/opencart_sample_data.sql');
|
|
||||||
} else {
|
|
||||||
$sql = file_get_contents($this->root_dir . 'tests/opencart_sample_data_3.sql');
|
|
||||||
}
|
|
||||||
|
|
||||||
$conn->exec("USE " . $this->opencart_config['db_database']);
|
$conn->exec("USE " . $this->opencart_config['db_database']);
|
||||||
|
|
||||||
|
|
|
@ -41,4 +41,63 @@ class ControllerRetailcrmAdminTest extends TestCase
|
||||||
$response = $this->dispatchAction('extension/module/retailcrm/uninstall_collector');
|
$response = $this->dispatchAction('extension/module/retailcrm/uninstall_collector');
|
||||||
$this->assertRegExp('/Connection settings/', $response->getOutput());
|
$this->assertRegExp('/Connection settings/', $response->getOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetAvailableTypes()
|
||||||
|
{
|
||||||
|
$data = $this->getDataForTestAvailableTypes();
|
||||||
|
$sites = end($data['site']);
|
||||||
|
$types = $data['types'];
|
||||||
|
|
||||||
|
$retailCrm = new ControllerExtensionModuleRetailcrm(self::$registry);
|
||||||
|
$class = new ReflectionClass($retailCrm);
|
||||||
|
$method = $class->getMethod('getAvailableTypes');
|
||||||
|
$method->setAccessible(true);
|
||||||
|
|
||||||
|
$result = $method->invokeArgs($retailCrm, [$sites, $types]);
|
||||||
|
|
||||||
|
$this->assertNotEmpty($result['opencart']);
|
||||||
|
$this->assertNotEmpty($result['retailcrm']);
|
||||||
|
$this->assertCount(2, $result['retailcrm']);
|
||||||
|
$this->assertNotEmpty($result['retailcrm']['test1']['code']);
|
||||||
|
$this->assertNotEmpty($result['retailcrm']['test4']['code']);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getDataForTestAvailableTypes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'site' => [
|
||||||
|
'opencart' => [
|
||||||
|
'code' => 'opencart',
|
||||||
|
'name' => 'OpenCart'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'types' => [
|
||||||
|
'opencart' => [
|
||||||
|
'test'
|
||||||
|
],
|
||||||
|
'retailcrm' => [
|
||||||
|
'test1' => [
|
||||||
|
'active' => true,
|
||||||
|
'sites' => [],
|
||||||
|
'code' => 'test1'
|
||||||
|
],
|
||||||
|
'test2' => [
|
||||||
|
'active' => false,
|
||||||
|
'sites' => [],
|
||||||
|
'code' => 'test2'
|
||||||
|
],
|
||||||
|
'test3' => [
|
||||||
|
'active' => true,
|
||||||
|
'sites' => ['otherSite'],
|
||||||
|
'code' => 'test3'
|
||||||
|
],
|
||||||
|
'test4' => [
|
||||||
|
'active' => true,
|
||||||
|
'sites' => ['cms1', 'cms2', 'opencart'],
|
||||||
|
'code' => 'test4'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,7 @@ class ModelRetailcrmEventAdminTest extends TestCase
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
if (getenv('TEST_SUITE') === '3.0') {
|
$eventModel = $this->loadModel('setting/event');
|
||||||
$eventModel = $this->loadModel('setting/event');
|
|
||||||
} else {
|
|
||||||
$eventModel = $this->loadModel('extension/event');
|
|
||||||
}
|
|
||||||
|
|
||||||
$eventModel->addEvent(self::CODE, 'test', 'test');
|
$eventModel->addEvent(self::CODE, 'test', 'test');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
TRUNCATE TABLE `oc_customer`;
|
|
||||||
INSERT INTO `oc_customer` (`customer_id`, `customer_group_id`, `store_id`, `language_id`, `firstname`, `lastname`, `email`, `telephone`, `fax`, `password`, `salt`, `cart`, `wishlist`, `newsletter`, `address_id`, `custom_field`, `ip`, `status`, `approved`, `safe`, `token`, `code`, `date_added`) VALUES ('1', '1', '0', '1', 'Test', 'Test', 'test@mail.ru', '+7 (000) 000-00-00', '', 'ed3798da75d6cdd695e99e87a60d587a10aa95ff', '51TalnrgH', '', '', '0', '1', '', '172.21.0.1', '1', '1', '0', '', '', '2018-06-07 13:50:08');
|
|
||||||
|
|
||||||
TRUNCATE TABLE `oc_address`;
|
|
||||||
INSERT INTO `oc_address` (`address_id`, `customer_id`, `firstname`, `lastname`, `company`, `address_1`, `address_2`, `city`, `postcode`, `country_id`, `zone_id`, `custom_field`) values (1, 1, 'Test', 'Test', '', 'Address 1', '', 'City', '111111', '176', '99', '');
|
|
||||||
|
|
||||||
TRUNCATE TABLE `oc_customer_activity`;
|
|
||||||
TRUNCATE TABLE `oc_customer_group`;
|
|
||||||
INSERT INTO `oc_customer_group` (`customer_group_id`, `approval`, `sort_order`) VALUES ('1', '0', '1');
|
|
||||||
INSERT INTO `oc_customer_group` (`customer_group_id`, `approval`, `sort_order`) VALUES ('2', '0', '1');
|
|
||||||
INSERT INTO `oc_customer_group` (`customer_group_id`, `approval`, `sort_order`) VALUES ('3', '0', '0');
|
|
||||||
|
|
||||||
TRUNCATE TABLE `oc_customer_group_description`;
|
|
||||||
INSERT INTO `oc_customer_group_description` (`customer_group_id`, `language_id`, `name`, `description`) VALUES ('1', '1', 'Default', 'test');
|
|
||||||
INSERT INTO `oc_customer_group_description` (`customer_group_id`, `language_id`, `name`, `description`) VALUES ('2', '1', 'Test2', 'test2');
|
|
||||||
INSERT INTO `oc_customer_group_description` (`customer_group_id`, `language_id`, `name`, `description`) VALUES ('3', '1', 'test3', 'test3');
|
|
||||||
|
|
||||||
TRUNCATE TABLE `oc_customer_history`;
|
|
||||||
TRUNCATE TABLE `oc_customer_ip`;
|
|
||||||
INSERT INTO `oc_customer_ip` (`customer_ip_id`, `customer_id`, `ip`, `date_added`) VALUES ('4', '1', '172.21.0.1', '2018-06-07 13:50:29');
|
|
||||||
|
|
||||||
TRUNCATE TABLE `oc_customer_login`;
|
|
||||||
TRUNCATE TABLE `oc_customer_online`;
|
|
||||||
TRUNCATE TABLE `oc_customer_reward`;
|
|
||||||
TRUNCATE TABLE `oc_customer_search`;
|
|
||||||
TRUNCATE TABLE `oc_customer_transaction`;
|
|
||||||
TRUNCATE TABLE `oc_customer_wishlist`;
|
|
||||||
TRUNCATE TABLE `oc_order`;
|
|
||||||
|
|
||||||
INSERT INTO `oc_order` (`order_id`, `invoice_no`, `invoice_prefix`, `store_id`, `store_name`, `store_url`, `customer_id`, `customer_group_id`, `firstname`, `lastname`, `email`, `telephone`, `fax`, `custom_field`, `payment_firstname`, `payment_lastname`, `payment_company`, `payment_address_1`, `payment_address_2`, `payment_city`, `payment_postcode`, `payment_country`, `payment_country_id`, `payment_zone`, `payment_zone_id`, `payment_address_format`, `payment_custom_field`, `payment_method`, `payment_code`, `shipping_firstname`, `shipping_lastname`, `shipping_company`, `shipping_address_1`, `shipping_address_2`, `shipping_city`, `shipping_postcode`, `shipping_country`, `shipping_country_id`, `shipping_zone`, `shipping_zone_id`, `shipping_address_format`, `shipping_custom_field`, `shipping_method`, `shipping_code`, `comment`, `total`, `order_status_id`, `affiliate_id`, `commission`, `marketing_id`, `tracking`, `language_id`, `currency_id`, `currency_code`, `currency_value`, `ip`, `forwarded_ip`, `user_agent`, `accept_language`, `date_added`, `date_modified`) VALUES ('1', '0', 'INV-2016-00', '0', 'Opencart', 'http://localhost:8000/', '1', '1', 'Test', 'Test', 'test@mail.ru', '+7 (000) 000-00-00', '', '', 'Test', 'Test', '', 'Address', 'Address 2', 'Test', '111111', 'Russian Federation', '176', 'Rostov-na-Donu', '99', '', '[]', 'Cash on delivery', 'cod', 'Test', 'Test', '', 'Address', 'Address 2', 'Test', '111111', 'Russian Federation', '176', 'Rostov-na-Donu', '99', '', '[]', 'Flat Rate', 'flat.flat', 'test comment', '106.0000', '1', '0', '0.0000', '0', '', '1', '1', 'USD', '1.00000000', '172.21.0.1', '', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36', 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7', '2018-06-07 13:51:10', '2018-06-07 13:51:23');
|
|
||||||
INSERT INTO `oc_order` (`order_id`, `invoice_no`, `invoice_prefix`, `store_id`, `store_name`, `store_url`, `customer_id`, `customer_group_id`, `firstname`, `lastname`, `email`, `telephone`, `fax`, `custom_field`, `payment_firstname`, `payment_lastname`, `payment_company`, `payment_address_1`, `payment_address_2`, `payment_city`, `payment_postcode`, `payment_country`, `payment_country_id`, `payment_zone`, `payment_zone_id`, `payment_address_format`, `payment_custom_field`, `payment_method`, `payment_code`, `shipping_firstname`, `shipping_lastname`, `shipping_company`, `shipping_address_1`, `shipping_address_2`, `shipping_city`, `shipping_postcode`, `shipping_country`, `shipping_country_id`, `shipping_zone`, `shipping_zone_id`, `shipping_address_format`, `shipping_custom_field`, `shipping_method`, `shipping_code`, `comment`, `total`, `order_status_id`, `affiliate_id`, `commission`, `marketing_id`, `tracking`, `language_id`, `currency_id`, `currency_code`, `currency_value`, `ip`, `forwarded_ip`, `user_agent`, `accept_language`, `date_added`, `date_modified`) VALUES ('2', '0', 'INV-2016-00', '0', 'Opencart', 'http://localhost:8000/', '0', '1', 'Test', 'Test', 'test@mail.ru', '+7 (000) 000-00-00', '', '[]', 'Test', 'Test', '', 'Address', 'Address 2', 'Test', '111111', 'Russian Federation', '176', 'Rostov-na-Donu', '99', '', '[]', 'Cash on delivery', 'cod', 'Test', 'Test', '', 'Address', 'Address 2', 'Test', '111111', 'Russian Federation', '176', 'Rostov-na-Donu', '99', '', '[]', 'Flat Rate', 'flat.flat', 'test comment', '85.0000', '1', '0', '0.0000', '0', '', '1', '1', 'USD', '1.00000000', '172.21.0.1', '', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36', 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7', '2018-06-07 13:53:50', '2018-06-07 13:54:00');
|
|
||||||
|
|
||||||
TRUNCATE TABLE `oc_order_history`;
|
|
||||||
INSERT INTO `oc_order_history` (`order_history_id`, `order_id`, `order_status_id`, `notify`, `comment`, `date_added`) VALUES ('19', '2', '1', '0', '', '2018-06-07 13:54:00');
|
|
||||||
INSERT INTO `oc_order_history` (`order_history_id`, `order_id`, `order_status_id`, `notify`, `comment`, `date_added`) VALUES ('18', '1', '1', '0', '', '2018-06-07 13:51:23');
|
|
||||||
|
|
||||||
TRUNCATE TABLE `oc_order_option`;
|
|
||||||
|
|
||||||
INSERT INTO `oc_order_option` (`order_option_id`, `order_id`, `order_product_id`, `product_option_id`, `product_option_value_id`, `name`, `value`, `type`) VALUES ('15', '2', '55', '226', '15', 'Select', 'Red', 'select');
|
|
||||||
|
|
||||||
TRUNCATE TABLE `oc_order_product`;
|
|
||||||
INSERT INTO `oc_order_product` (`order_product_id`, `order_id`, `product_id`, `name`, `model`, `quantity`, `price`, `total`, `tax`, `reward`) VALUES ('54', '1', '40', 'iPhone', 'product 11', '1', '101.0000', '101.0000', '18.0000', '20');
|
|
||||||
INSERT INTO `oc_order_product` (`order_product_id`, `order_id`, `product_id`, `name`, `model`, `quantity`, `price`, `total`, `tax`, `reward`) VALUES ('55', '2', '30', 'Canon EOS 5D', 'Product 3', '1', '80.0000', '80.0000', '18.0000', '200');
|
|
||||||
|
|
||||||
TRUNCATE TABLE `oc_order_recurring`;
|
|
||||||
TRUNCATE TABLE `oc_order_recurring_transaction`;
|
|
||||||
TRUNCATE TABLE `oc_order_total`;
|
|
||||||
|
|
||||||
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('162', '1', 'shipping', 'Flat Rate', '5.0000', '3');
|
|
||||||
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('161', '1', 'sub_total', 'Sub-Total', '101.0000', '1');
|
|
||||||
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('164', '2', 'sub_total', 'Sub-Total', '80.0000', '1');
|
|
||||||
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('165', '2', 'shipping', 'Flat Rate', '5.0000', '3');
|
|
||||||
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('163', '1', 'total', 'Total', '106.0000', '9');
|
|
||||||
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('166', '2', 'total', 'Total', '85.0000', '9');
|
|
||||||
INSERT INTO `oc_product_special` (`product_id`, `customer_group_id`, `priority`, `price`,`date_start`, `date_end`) values ('42', '2', '1', '110.000', CURDATE(), ADDDATE(CURDATE(),INTERVAL 10 DAY));
|
|
||||||
INSERT INTO `oc_product_special` (`product_id`, `customer_group_id`, `priority`, `price`,`date_start`, `date_end`) values ('40', '1', '1', '50.000', CURDATE(), ADDDATE(CURDATE(),INTERVAL 10 DAY));
|
|
||||||
|
|
||||||
TRUNCATE TABLE `oc_order_voucher`;
|
|
|
@ -3,6 +3,7 @@
|
||||||
require_once __DIR__ . '/../' . getenv('TEST_SUITE') . '/TestCase.php';
|
require_once __DIR__ . '/../' . getenv('TEST_SUITE') . '/TestCase.php';
|
||||||
|
|
||||||
class RetailcrmTest extends TestCase {
|
class RetailcrmTest extends TestCase {
|
||||||
|
|
||||||
public function testGetOrderManager() {
|
public function testGetOrderManager() {
|
||||||
$retailcrm = new retailcrm\Retailcrm(static::$registry);
|
$retailcrm = new retailcrm\Retailcrm(static::$registry);
|
||||||
|
|
||||||
|
@ -15,4 +16,26 @@ class RetailcrmTest extends TestCase {
|
||||||
|
|
||||||
$this->assertInstanceOf(\retailcrm\service\OrderManager::class, $manager);
|
$this->assertInstanceOf(\retailcrm\service\OrderManager::class, $manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetWeightOption() {
|
||||||
|
$retailCrm = new \retailcrm\Retailcrm(self::$registry);
|
||||||
|
|
||||||
|
$reflection = new ReflectionClass($retailCrm);
|
||||||
|
$reflectionMethod = $reflection->getMethod('getWeightOption');
|
||||||
|
$reflectionMethod->setAccessible('true');
|
||||||
|
|
||||||
|
$result = $reflectionMethod->invokeArgs(
|
||||||
|
$retailCrm,
|
||||||
|
[['weight_prefix' => '+', 'weight' => 5]]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(5, $result);
|
||||||
|
|
||||||
|
$result = $reflectionMethod->invokeArgs(
|
||||||
|
$retailCrm,
|
||||||
|
[['weight_prefix' => '-', 'weight' => 5]]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(-5, $result);;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ class DataRepositoryAdminTest extends TestCase {
|
||||||
|
|
||||||
$this->assertNotEmpty($zone);
|
$this->assertNotEmpty($zone);
|
||||||
$this->assertNotEmpty($zone['zone_id']);
|
$this->assertNotEmpty($zone['zone_id']);
|
||||||
|
|
||||||
|
$repository->getZoneByName('Rostov-na-Do\'nu');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetCurrencyByCode() {
|
public function testGetCurrencyByCode() {
|
||||||
|
|
|
@ -21,17 +21,26 @@ class CorporateCustomerBuilderTest extends TestCase {
|
||||||
'shipping_address_2' => ''
|
'shipping_address_2' => ''
|
||||||
);
|
);
|
||||||
|
|
||||||
$corp = \retailcrm\service\CorporateCustomerBuilder::create()
|
$builder = \retailcrm\service\CorporateCustomerBuilder::create();
|
||||||
|
$corp = $builder
|
||||||
->setCustomerExternalId(1)
|
->setCustomerExternalId(1)
|
||||||
->setCompany('Company')
|
->setCompany('Company')
|
||||||
->addCompany($data)
|
->addCompany($data)
|
||||||
->addAddress($data)
|
->addAddress($data)
|
||||||
->build();
|
->build();
|
||||||
|
$company_with_is_main = $builder->setIsMainCompany(true)->buildCompany($data);
|
||||||
|
$company_with_address = $builder->setCompanyAddressId(12)->buildCompany($data);
|
||||||
|
|
||||||
$this->assertNotEmpty($corp);
|
self::assertNotEmpty($corp);
|
||||||
$this->assertNotEmpty($corp['addresses']);
|
self::assertNotEmpty($corp['addresses']);
|
||||||
$this->assertNotEmpty($corp['companies']);
|
self::assertNotEmpty($corp['companies']);
|
||||||
$this->assertNotEmpty($corp['customerContacts'][0]['customer']);
|
self::assertFalse(isset($corp['companies'][0]['isMain']));
|
||||||
$this->assertEquals(1, $corp['customerContacts'][0]['customer']['externalId']);
|
self::assertArrayHasKey('isMain', $company_with_is_main);
|
||||||
|
self::assertTrue($company_with_is_main['isMain']);
|
||||||
|
self::assertArrayHasKey('address', $company_with_address);
|
||||||
|
self::assertNotEmpty($company_with_address['address']);
|
||||||
|
self::assertEquals(12, $company_with_address['address']['id']);
|
||||||
|
self::assertNotEmpty($corp['customerContacts'][0]['customer']);
|
||||||
|
self::assertEquals(1, $corp['customerContacts'][0]['customer']['externalId']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,23 +10,33 @@ class OrderManagerTest extends TestCase {
|
||||||
public function testCreateOrderWithCustomer() {
|
public function testCreateOrderWithCustomer() {
|
||||||
$proxy = $this->getMockBuilder(\RetailcrmProxy::class)
|
$proxy = $this->getMockBuilder(\RetailcrmProxy::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->setMethods(['ordersCreate'])
|
->setMethods(['ordersCreate','customersGet'])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$proxy->expects($this->once())->method('ordersCreate');
|
$proxy->expects($this->once())->method('ordersCreate');
|
||||||
|
|
||||||
$customer_manager = new \retailcrm\service\CustomerManager(
|
$proxy->expects($this->once())
|
||||||
$proxy,
|
->method('customersGet')
|
||||||
\retailcrm\factory\CustomerConverterFactory::create(static::$registry)
|
->willReturn(new \RetailcrmApiResponse(
|
||||||
);
|
200,
|
||||||
|
json_encode(
|
||||||
|
[
|
||||||
|
'success' => true,
|
||||||
|
'pagination' => [
|
||||||
|
'limit'=> 20,
|
||||||
|
'totalCount' => 0,
|
||||||
|
'currentPage' => 1,
|
||||||
|
'totalPageCount' => 0
|
||||||
|
],
|
||||||
|
'customer' => [
|
||||||
|
'id' => 1,
|
||||||
|
'externalId' => 1
|
||||||
|
]
|
||||||
|
]
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
$converter = \retailcrm\factory\OrderConverterFactory::create(static::$registry);
|
$order_manager = $this->getOrderManager($proxy);
|
||||||
$corporate_customer = new \retailcrm\service\CorporateCustomer(
|
|
||||||
$proxy, new \retailcrm\repository\CustomerRepository(static::$registry)
|
|
||||||
);
|
|
||||||
$settings_manager = new \retailcrm\service\SettingsManager(static::$registry);
|
|
||||||
|
|
||||||
$order_manager = new \retailcrm\service\OrderManager($proxy, $customer_manager, $converter, $corporate_customer, $settings_manager);
|
|
||||||
|
|
||||||
$orderCheckoutModel = $this->loadModel('checkout/order');
|
$orderCheckoutModel = $this->loadModel('checkout/order');
|
||||||
$orderAccountModel = $this->loadModel('account/order');
|
$orderAccountModel = $this->loadModel('account/order');
|
||||||
|
@ -76,17 +86,7 @@ class OrderManagerTest extends TestCase {
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
$customer_manager = new \retailcrm\service\CustomerManager(
|
$order_manager = $this->getOrderManager($proxy);
|
||||||
$proxy,
|
|
||||||
\retailcrm\factory\CustomerConverterFactory::create(static::$registry)
|
|
||||||
);
|
|
||||||
|
|
||||||
$converter = \retailcrm\factory\OrderConverterFactory::create(static::$registry);
|
|
||||||
$corporate_customer = new \retailcrm\service\CorporateCustomer(
|
|
||||||
$proxy, new \retailcrm\repository\CustomerRepository(static::$registry)
|
|
||||||
);
|
|
||||||
$settings_manager = new \retailcrm\service\SettingsManager(static::$registry);
|
|
||||||
$order_manager = new \retailcrm\service\OrderManager($proxy, $customer_manager, $converter, $corporate_customer, $settings_manager);
|
|
||||||
|
|
||||||
$orderCheckoutModel = $this->loadModel('checkout/order');
|
$orderCheckoutModel = $this->loadModel('checkout/order');
|
||||||
$orderAccountModel = $this->loadModel('account/order');
|
$orderAccountModel = $this->loadModel('account/order');
|
||||||
|
@ -143,17 +143,7 @@ class OrderManagerTest extends TestCase {
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
$customer_manager = new \retailcrm\service\CustomerManager(
|
$order_manager = $this->getOrderManager($proxy);
|
||||||
$proxy,
|
|
||||||
\retailcrm\factory\CustomerConverterFactory::create(static::$registry)
|
|
||||||
);
|
|
||||||
|
|
||||||
$converter = \retailcrm\factory\OrderConverterFactory::create(static::$registry);
|
|
||||||
$corporate_customer = new \retailcrm\service\CorporateCustomer(
|
|
||||||
$proxy, new \retailcrm\repository\CustomerRepository(static::$registry)
|
|
||||||
);
|
|
||||||
$settings_manager = new \retailcrm\service\SettingsManager(static::$registry);
|
|
||||||
$order_manager = new \retailcrm\service\OrderManager($proxy, $customer_manager, $converter, $corporate_customer, $settings_manager);
|
|
||||||
|
|
||||||
$orderCheckoutModel = $this->loadModel('checkout/order');
|
$orderCheckoutModel = $this->loadModel('checkout/order');
|
||||||
$orderAccountModel = $this->loadModel('account/order');
|
$orderAccountModel = $this->loadModel('account/order');
|
||||||
|
@ -203,17 +193,7 @@ class OrderManagerTest extends TestCase {
|
||||||
$proxy->expects($this->once())->method('ordersGet')->willReturn($ordersGetResponse);
|
$proxy->expects($this->once())->method('ordersGet')->willReturn($ordersGetResponse);
|
||||||
$proxy->expects($this->once())->method('ordersPaymentEdit');
|
$proxy->expects($this->once())->method('ordersPaymentEdit');
|
||||||
|
|
||||||
$customer_manager = new \retailcrm\service\CustomerManager(
|
$order_manager = $this->getOrderManager($proxy);
|
||||||
$proxy,
|
|
||||||
\retailcrm\factory\CustomerConverterFactory::create(static::$registry)
|
|
||||||
);
|
|
||||||
|
|
||||||
$converter = \retailcrm\factory\OrderConverterFactory::create(static::$registry);
|
|
||||||
$settings_manager = new \retailcrm\service\SettingsManager(static::$registry);
|
|
||||||
$corporate_customer = new \retailcrm\service\CorporateCustomer(
|
|
||||||
$proxy, new \retailcrm\repository\CustomerRepository(static::$registry)
|
|
||||||
);
|
|
||||||
$order_manager = new \retailcrm\service\OrderManager($proxy, $customer_manager, $converter, $corporate_customer, $settings_manager);
|
|
||||||
|
|
||||||
$orderCheckoutModel = $this->loadModel('checkout/order');
|
$orderCheckoutModel = $this->loadModel('checkout/order');
|
||||||
$orderAccountModel = $this->loadModel('account/order');
|
$orderAccountModel = $this->loadModel('account/order');
|
||||||
|
@ -233,6 +213,50 @@ class OrderManagerTest extends TestCase {
|
||||||
$order_manager->editOrder($order, $products, $totals);
|
$order_manager->editOrder($order, $products, $totals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPrepareOrderTotals() {
|
||||||
|
$proxy = $this->getMockBuilder(\RetailcrmProxy::class)
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$order_manager = $this->getOrderManager($proxy);
|
||||||
|
|
||||||
|
$orderCheckoutModel = $this->loadModel('checkout/order');
|
||||||
|
$orderAccountModel = $this->loadModel('account/order');
|
||||||
|
$order_id = self::ORDER_WITH_CUST_ID;
|
||||||
|
$order = $orderCheckoutModel->getOrder($order_id);
|
||||||
|
$products = $orderAccountModel->getOrderProducts($order_id);
|
||||||
|
$totals = $this->getOrderTotals($order_id);
|
||||||
|
|
||||||
|
foreach ($products as $key => $product) {
|
||||||
|
$productOptions = $orderAccountModel->getOrderOptions($order_id, $product['order_product_id']);
|
||||||
|
|
||||||
|
if (!empty($productOptions)) {
|
||||||
|
$products[$key]['option'] = $productOptions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $order_manager->prepareOrder($order, $products, $totals);
|
||||||
|
|
||||||
|
$this->assertEquals(15, $data['discountManualAmount']);
|
||||||
|
$this->assertEquals(115, $data['payments'][0]['amount']);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getOrderManager($proxy)
|
||||||
|
{
|
||||||
|
$customer_manager = new \retailcrm\service\CustomerManager(
|
||||||
|
$proxy,
|
||||||
|
\retailcrm\factory\CustomerConverterFactory::create(static::$registry)
|
||||||
|
);
|
||||||
|
|
||||||
|
$converter = \retailcrm\factory\OrderConverterFactory::create(static::$registry);
|
||||||
|
$corporate_customer = new \retailcrm\service\CorporateCustomer(
|
||||||
|
$proxy, new \retailcrm\repository\CustomerRepository(static::$registry)
|
||||||
|
);
|
||||||
|
$settings_manager = new \retailcrm\service\SettingsManager(static::$registry);
|
||||||
|
|
||||||
|
return new \retailcrm\service\OrderManager($proxy, $customer_manager, $converter, $corporate_customer, $settings_manager);
|
||||||
|
}
|
||||||
|
|
||||||
private function getOrder($id)
|
private function getOrder($id)
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
@ -247,4 +271,42 @@ class OrderManagerTest extends TestCase {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getOrderTotals($id)
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
"order_total_id" => "1",
|
||||||
|
"order_id" => $id,
|
||||||
|
"code" => "total",
|
||||||
|
"title" => "Total",
|
||||||
|
"value" => "115",
|
||||||
|
"sort_order" => "9",
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"order_total_id" => "2",
|
||||||
|
"order_id" => $id,
|
||||||
|
"code" => "sub_total",
|
||||||
|
"title" => "Sum",
|
||||||
|
"value" => "110",
|
||||||
|
"sort_order" => "1",
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"order_total_id" => "3",
|
||||||
|
"order_id" => $id,
|
||||||
|
"code" => "voucher",
|
||||||
|
"title" => "Voucher",
|
||||||
|
"value" => "15",
|
||||||
|
"sort_order" => "9",
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"order_total_id" => "4",
|
||||||
|
"order_id" => $id,
|
||||||
|
"code" => "shipping",
|
||||||
|
"title" => "Flat Shipping Rate",
|
||||||
|
"value" => "5",
|
||||||
|
"sort_order" => "3",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ class RetailcrmCustomerConverterTest extends TestCase {
|
||||||
$customer_data = $model->getCustomer(1);
|
$customer_data = $model->getCustomer(1);
|
||||||
|
|
||||||
$customer = $converter
|
$customer = $converter
|
||||||
->initCustomerData($customer_data, array())
|
->initCustomerData($customer_data, [], true)
|
||||||
->setCustomerData()
|
->setCustomerData()
|
||||||
->getCustomer();
|
->getCustomer();
|
||||||
|
|
||||||
|
@ -20,23 +20,24 @@ class RetailcrmCustomerConverterTest extends TestCase {
|
||||||
$this->assertEquals($customer_data['lastname'], $customer['lastName']);
|
$this->assertEquals($customer_data['lastname'], $customer['lastName']);
|
||||||
$this->assertEquals($customer_data['email'], $customer['email']);
|
$this->assertEquals($customer_data['email'], $customer['email']);
|
||||||
$this->assertEquals($customer_data['date_added'], $customer['createdAt']);
|
$this->assertEquals($customer_data['date_added'], $customer['createdAt']);
|
||||||
|
$this->assertTrue($customer['subscribed']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetAddress() {
|
public function testSetAddress() {
|
||||||
$converter = \retailcrm\factory\CustomerConverterFactory::create(static::$registry);
|
$converter = \retailcrm\factory\CustomerConverterFactory::create(static::$registry);
|
||||||
$model = $this->loadModel('account/customer');
|
$model = $this->loadModel('account/customer');
|
||||||
$customer_data = $model->getCustomer(static::CUSTOMER_ID);
|
$customer_data = $model->getCustomer(static::CUSTOMER_ID);
|
||||||
$address = array(
|
$address = [
|
||||||
'postcode' => '111111',
|
'postcode' => '111111',
|
||||||
'iso_code_2' => 'EN',
|
'iso_code_2' => 'EN',
|
||||||
'zone' => 'Zone',
|
'zone' => 'Zone',
|
||||||
'city' => 'City',
|
'city' => 'City',
|
||||||
'address_1' => 'Address',
|
'address_1' => 'Address',
|
||||||
'address_2' => ''
|
'address_2' => ''
|
||||||
);
|
];
|
||||||
|
|
||||||
$customer = $converter
|
$customer = $converter
|
||||||
->initCustomerData($customer_data, $address)
|
->initCustomerData($customer_data, $address, null)
|
||||||
->setAddress()
|
->setAddress()
|
||||||
->getCustomer();
|
->getCustomer();
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,35 @@ class RetailcrmOrderConverterTest extends TestCase {
|
||||||
$this->assertEquals('cod', $order['payments'][0]['type']);
|
$this->assertEquals('cod', $order['payments'][0]['type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSetEmptyPayment() {
|
||||||
|
$order_checkout_model = $this->loadModel('checkout/order');
|
||||||
|
$order_account_model = $this->loadModel('account/order');
|
||||||
|
|
||||||
|
$order_data = $order_checkout_model->getOrder(static::ORDER_WITH_CUST_ID);
|
||||||
|
$products = $order_account_model->getOrderProducts(static::ORDER_WITH_CUST_ID);
|
||||||
|
$totals = $order_account_model->getOrderTotals(static::ORDER_WITH_CUST_ID);
|
||||||
|
|
||||||
|
foreach ($products as $key => $product) {
|
||||||
|
$productOptions = $order_account_model->getOrderOptions(static::ORDER_WITH_CUST_ID, $product['order_product_id']);
|
||||||
|
|
||||||
|
if (!empty($productOptions)) {
|
||||||
|
$products[$key]['option'] = $productOptions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$converter = \retailcrm\factory\OrderConverterFactory::create(static::$registry);
|
||||||
|
|
||||||
|
unset($order_data['payment_code']);
|
||||||
|
|
||||||
|
$order = $converter->initOrderData(
|
||||||
|
$order_data,
|
||||||
|
$products,
|
||||||
|
$totals
|
||||||
|
)->setPayment()->getOrder();
|
||||||
|
|
||||||
|
$this->assertArrayNotHasKey('payments', $order);
|
||||||
|
}
|
||||||
|
|
||||||
public function testSetDelivery() {
|
public function testSetDelivery() {
|
||||||
$order_checkout_model = $this->loadModel('checkout/order');
|
$order_checkout_model = $this->loadModel('checkout/order');
|
||||||
$order_account_model = $this->loadModel('account/order');
|
$order_account_model = $this->loadModel('account/order');
|
||||||
|
|
Loading…
Add table
Reference in a new issue