Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/implement s2s calls #6

Merged
merged 7 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: CI

on:
push:
branches:
- 'bugfix/*'
- 'feature/*'

jobs:
merge-branches:
runs-on: ubuntu-latest
steps:
- name: Set Git identity
run: |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.name "${GITHUB_ACTOR}"

- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0 # Ensure all branches and history are fetched

- name: Fetch all branches
run: git fetch --all

- name: Delete remote dev branch if exists
run: git push origin --delete dev || true

- name: Create dev branch from master
run: |
git checkout -b dev origin/master
git push origin dev --force

- name: Merge feature branch into dev
run: |
git checkout dev
git merge --no-ff ${{ github.event.ref }}
git push origin dev --force

build:
runs-on: ubuntu-latest
needs: merge-branches

services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: CI
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping -h localhost" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
ini-values: error_reporting=-1
- name: Install and configure WordPress for Testing
run: |
ls -l
git clone --depth=1 --branch=trunk https://github.com/WordPress/wordpress-develop.git wordpress
cp wordpress/wp-tests-config-sample.php wordpress/wp-tests-config.php
sed -i "s/youremptytestdbnamehere/CI/" wordpress/wp-tests-config.php
sed -i "s/yourusernamehere/root/" wordpress/wp-tests-config.php
sed -i "s/yourpasswordhere/root/" wordpress/wp-tests-config.php
sed -i "s|localhost|127.0.0.1|" wordpress/wp-tests-config.php

- name: Install WordPress dependencies
run: |
cd wordpress/src
composer require wp-cli/wp-cli-bundle
./vendor/bin/wp --version
./vendor/bin/wp config create --dbname=CI --dbuser=root --dbpass=root --dbhost=127.0.0.1
./vendor/bin/wp core install --url=http://localhost --title="Test Site" --admin_user=admin --admin_password=password [email protected] --skip-email

- name: Copy plugin files on wordpress
run: |
rsync -av --exclude='wordpress' --exclude='.git' $GITHUB_WORKSPACE/ wordpress/src/wp-content/plugins/kelkoo-sales-tracking

- name: Install and Activate WooCommerce and KST plugins
run: |
cd wordpress/src
./vendor/bin/wp plugin install woocommerce --activate
echo "Wordpress version:"
./vendor/bin/wp core version
./vendor/bin/wp plugin activate kelkoo-sales-tracking
echo
echo "Plugins installed:"
./vendor/bin/wp plugin list
echo
echo "Tables presents :"
./vendor/bin/wp db tables

- name: Install PHPUnit and Polyfills
run: |
cd wordpress/src
if [ ! -f composer.json ]; then
echo '{}' > composer.json
fi
composer require --dev phpunit/phpunit yoast/phpunit-polyfills
ls -l vendor/yoast/phpunit-polyfills
find -iname phpunit

- name: Run plugin tests
env:
WP_RUN_CORE_TESTS: 0
WP_TESTS_PHPUNIT_POLYFILLS_PATH: ${{ github.workspace }}/wordpress/vendor/yoast/phpunit-polyfills
run: |
cd wordpress/src
echo "WP_RUN_CORE_TESTS=$WP_RUN_CORE_TESTS"
echo "WP_TESTS_PHPUNIT_POLYFILLS_PATH=$WP_TESTS_PHPUNIT_POLYFILLS_PATH"
./vendor/bin/phpunit --bootstrap wp-content/plugins/kelkoo-sales-tracking/tests/bootstrap.php --configuration wp-content/plugins/kelkoo-sales-tracking/phpunit.xml.dist
28 changes: 0 additions & 28 deletions .github/workflows/create_ci_branch.yml

This file was deleted.

8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ To install the Kelkoo Group sales tracking plugin, you can have a look at [Kelko
5. Complete the form with information related to your kelkoo group subscription
6. Done!

*Installation via Wordpress Cli*
1. Log in to your site with SSH
2. cd to your sites root wordpress folder
3. Run wp plugin install ```wp plugin install kelkoogroup-sales-tracking --activate```
4. On plugin page go to “Settings” and click on the “Kelkoogroup” link
5. Complete the form with information related to your kelkoo group subscription
6. Done!

*Installation from source*
1. Go to folder `/wp-content/plugins` and unzip `woocommerce-kelkoogroup-sales-tracking` file
Expand All @@ -32,7 +39,6 @@ To install the Kelkoo Group sales tracking plugin, you can have a look at [Kelko
4. Complete the form with information related to your kelkoo group subscription
5. Done!


## Settings
- Configure the kelkoogroup setting via Settings > Kelkoogroup

Expand Down
6 changes: 3 additions & 3 deletions admin/class-kelkoogroup-salestracking-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ function kelkoogroup_salestracking_multicomid_render( ) {
}

function kelkoogroup_salestracking_settings_intro_section_callback( ) {
echo __( "<p>Kelkoogroup Sales Tracking requires a few configuration.</p>",'kelkoogroup-sales-tracking' );
echo esc_html__( "<p>Kelkoogroup Sales Tracking requires a few configuration.</p>",'kelkoogroup-sales-tracking' );
}

function kelkoogroup_salestracking_settings_onecampaign_section_callback( ) {
echo __( "<p> Merchant Identifier: This is the unique ID representing your shop within the Kelkoo system. You got it by email at your subscription, else to recover it you can ask your Kelkoogroup account manager. </p>
echo esc_html__( "<p> Merchant Identifier: This is the unique ID representing your shop within the Kelkoo system. You got it by email at your subscription, else to recover it you can ask your Kelkoogroup account manager. </p>
<p> Country is the 2-letter country code for the country on which your products are listed on Kelkoo:
'at' for Austria, 'be' for Belgium, 'br' for Brazil, 'ch' for Switzerland, 'cz' for Czech Republic, 'de' for Germany,
'dk' for Denmark, 'es' for Spain, 'fi' for Finland, 'fr' for France, 'ie ' for Ireland, 'it' for Italy, 'mx' for Mexico,
Expand All @@ -110,7 +110,7 @@ function kelkoogroup_salestracking_settings_onecampaign_section_callback( ) {
}

function kelkoogroup_salestracking_settings_multicomid_section_callback( ) {
echo __( "<p> Multi merchant information : If you need to configure multiple merchant information (you have multiple Merchant Identifier/Country), you can copy/paste the sample and update it.",
echo esc_html__( "<p> Multi merchant information : If you need to configure multiple merchant information (you have multiple Merchant Identifier/Country), you can copy/paste the sample and update it.",
'kelkoogroup-sales-tracking' );
}

Expand Down
28 changes: 27 additions & 1 deletion inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,37 @@


/**
* functions.php
* Add lead tag
*/
function kelkoogroup_salestracking_call_leadtag_js() {
echo '<script async="true" type="text/javascript" src="https://s.kk-resources.com/leadtag.js" ></script>';
}

/**
* Stores identifiers from URL parameters in transients.
*
* This function iterates over predefined URL parameters and their associated transient keys.
* If any of these parameters are present in the URL, their values are stored in corresponding transients
* with a lifespan of 365 days.
*/
function kelkoogroup_salestracking_store_identifiers_from_url() {
// Define an array of parameters and their associated keys
$parameters = array(
'kk' => 'kelkoogroup_salestracking_kk_identifier',
'gclid' => 'kelkoogroup_salestracking_gclid_identifier',
'kgclid' => 'kelkoogroup_salestracking_gclid_identifier',
'msclkid' => 'kelkoogroup_salestracking_msclkid_identifier'
);

// Iterate over the array of parameters
foreach ($parameters as $param_key => $transient_key) {
// Check if the parameter is present in the URL
if (isset($_GET[$param_key])) {
// Store the value of the parameter in a transient with a lifespan of 365 days
set_transient($transient_key, $_GET[$param_key], 365 * DAY_IN_SECONDS);
}
}
}

add_action( 'wp_head', 'kelkoogroup_salestracking_call_leadtag_js' );
add_action( 'init', 'kelkoogroup_salestracking_store_identifiers_from_url');
11 changes: 11 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/bootstrap.php"
colors="true"
stopOnFailure="false"
stopOnError="false">
<testsuites>
<testsuite name="Kelkoogroup Sales Tracking Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>
26 changes: 24 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Contributors: kelkoogroup
Tags: kelkoogroup, sales, tracking, php, woocommerce
Requires at least: 4.0.0
Tested up to: 6.4
Stable tag: 1.0.11
Tested up to: 6.5.3
Stable tag: 2.0.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -36,6 +36,13 @@ To install the Kelkoo Group sales tracking plugin:
5. Complete the form with information related to your kelkoo group subscription
6. Done!

*Installation via Wordpress Cli*
1. Log in to your site with SSH
2. cd to your sites root wordpress folder
3. Run wp plugin install ```wp plugin install kelkoogroup-sales-tracking --activate```
4. On plugin page go to “Settings” and click on the “Kelkoogroup” link
5. Complete the form with information related to your kelkoo group subscription
6. Done!

*Installation via FTP Client Software*

Expand All @@ -46,6 +53,18 @@ To install the Kelkoo Group sales tracking plugin:
5. Complete the form with information related to your kelkoo group subscription
6. Done!


*Installation via Wordpress Cli*

1. Launch activation command through the wordpress-cli
```
wp plugin install kelkoogroup-sales-tracking --activate --path=/var/www/html
```
2. On plugin page go to “Settings” and click on the “Kelkoogroup” link
3. Complete the form with information related to your kelkoo group subscription
4. Done!


*Kelkoo Group settings*

Once your subscription has been done, you will be able to access your Merchant Extranet Dashboard and retrieve the country code and comId information.
Expand All @@ -66,6 +85,9 @@ Once your subscription has been done, you will be able to access your Merchant E

== Changelog ==

= 2.0.0 =
* Implement S2S call

= 1.0.11 =
* Tested up to 6.4

Expand Down
Loading
Loading