Skip to content

Commit

Permalink
Merge pull request #76 from DripEmail/eci-1860-update-hpos-compatible
Browse files Browse the repository at this point in the history
ECI-1860 - Verify and enable HPOS compatibility
  • Loading branch information
diegodrip authored Jul 6, 2023
2 parents 6399a9c + a2251db commit 50e6436
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
/devtools_wp/db_data/
/devtools_wp/cypress/screenshots/
/dist

.DS_Store
Binary file modified assets/banner-1544x500.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/banner-772x250.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshot-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshot-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshot-3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshot-4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshot-5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions devtools_wp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM wordpress:6.0.3-php8.1-apache
FROM wordpress:6.2.2-php8.1-apache

RUN curl https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -o /usr/local/bin/wp && chmod +x /usr/local/bin/wp
RUN apt-get update && apt-get install -y less unzip vim wget vim-tiny net-tools

RUN curl https://downloads.wordpress.org/plugin/woocommerce.5.2.2.zip -o /usr/src/woocommerce.zip && cd /usr/src/wordpress/wp-content/plugins && unzip /usr/src/woocommerce.zip
RUN curl https://downloads.wordpress.org/plugin/woocommerce.7.8.2.zip -o /usr/src/woocommerce.zip && cd /usr/src/wordpress/wp-content/plugins && unzip /usr/src/woocommerce.zip
14 changes: 7 additions & 7 deletions devtools_wp/cypress/integration/OrderInteractions/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ Then('I add a widget to my cart', () => {
})

Then("the page includes a Drip JS API call", () => {
cy.get('script[src="http://localhost:3007/wp-content/plugins/drip/src/customer_identify.js?ver=6.0.3"]').should('have.length', 1)
cy.get('script[src="http://localhost:3007/wp-content/plugins/drip/src/customer_identify.js?ver=6.2.2"]').should('have.length', 1)

cy.window().then(function(win) {
expect(win._dcq).to.have.lengthOf(1)
const call = win._dcq[0]
cy.window().then(function(window) {
expect(window._dcq).to.have.lengthOf(1)
const call = window._dcq[0]
expect(call).to.have.lengthOf(2)
expect(call[0]).to.eq("identify")
const identify_data = call[1]
Expand All @@ -38,9 +38,9 @@ Then('I add a widget to my cart', () => {
})

Then("the page does not make Drip JS API call", () => {
cy.get('script[src="http://localhost:3007/wp-content/plugins/drip/src/customer_identify.js?ver=6.0.3"]').should('have.length', 0)
cy.get('script[src="http://localhost:3007/wp-content/plugins/drip/src/customer_identify.js?ver=6.2.2"]').should('have.length', 0)

cy.window().then(function(win) {
expect(Object.keys(win)).to.not.include('_dcq')
cy.window().then(function(window) {
expect(Object.keys(window)).to.not.include('_dcq')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Then("the page includes a Drip JS API call", () => {
expect(call[1]).to.eq("Viewed a product")

const product = call[2]
expect(product.product_id.toString()).to.eq('12') // only works because we reset the entire db with each scenerio
expect(product.product_variant_id.toString()).to.eq('12')
expect(product.product_id.toString()).to.eq('16') // only works because we reset the entire db with each scenerio
expect(product.product_variant_id.toString()).to.eq('16')
expect(product.sku).to.eq('fair-widg-12345')
expect(product.name).to.eq('My Fair Widget')
expect(product.price.toString()).to.eq('1099')
Expand All @@ -39,8 +39,8 @@ Then("the page includes a null-price Drip JS API call", () => {
expect(call[1]).to.eq("Viewed a product")

const product = call[2]
expect(product.product_id.toString()).to.eq('12') // only works because we reset the entire db with each scenerio
expect(product.product_variant_id.toString()).to.eq('12')
expect(product.product_id.toString()).to.eq('16') // only works because we reset the entire db with each scenerio
expect(product.product_variant_id.toString()).to.eq('16')
expect(product.sku).to.eq('fair-widg-12345-null')
expect(product.name).to.eq('My Fair Widget Null')
expect(product.price.toString()).to.eq('0')
Expand Down
2 changes: 2 additions & 0 deletions devtools_wp/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ docker-compose exec -T db /bin/bash -c 'while ! mysql --protocol TCP -u"$MYSQL_U
woocommerce_setup_script=$(cat <<SCRIPT
cd /var/www/html/ && \
/usr/local/bin/wp core install --url="http://localhost:$port" --title="drip_woocommerce_test" --admin_user="drip" --admin_email="[email protected]" --admin_password="abc1234567890" --skip-email && \
/usr/local/bin/wp option set woocommerce_feature_custom_order_tables_enabled yes && \
/usr/local/bin/wp plugin activate woocommerce && \
/usr/local/bin/wp plugin activate drip; \
/usr/local/bin/wp media import https://cdn3.iconfinder.com/data/icons/nature-emoji/50/Forest-512.png
Expand All @@ -21,6 +22,7 @@ CART_PAGE_ID=\$(/usr/local/bin/wp post create --post_type=page --post_author="dr
CHKOUT_PAGE_ID=\$(/usr/local/bin/wp post create --post_type=page --post_author="drip" --post_title="My Fair Checkout" --post_name="My Fair Checkout" --post_content="[woocommerce_checkout]" --post_status="publish" --porcelain) && \
/usr/local/bin/wp option set woocommerce_checkout_page_id \$CHKOUT_PAGE_ID --autoload='yes'; \
/usr/local/bin/wp option set woocommerce_cod_settings '{"enabled":"yes","title":"Cash on delivery","description":"Pay with cash upon delivery.","instructions":"Pay with cash upon delivery.","enable_for_methods":"","enable_for_virtual":"yes"}' --autoload='yes' --format='json'; \
/usr/local/bin/wp wc update; \
if ! grep -q drip_woo_test_force_mocks wp-includes/functions.php; then
cat << "EOF" >> wp-includes/functions.php
function drip_woo_test_force_mocks(\$is_external, \$host) {
Expand Down
11 changes: 9 additions & 2 deletions drip.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,24 @@
Plugin Name: Drip for WooCommerce
Plugin URI: https://github.com/DripEmail/drip-woocommerce
Description: A WordPress plugin to connect to Drip's WooCommerce integration
Version: 1.1.3
Version: 1.1.4
Author: Drip
Author URI: https://www.drip.com/
License: GPLv2
WC requires at least: 3.0
WC tested up to: 7.0.1
WC tested up to: 7.8.2
*/

defined( 'ABSPATH' ) || die( 'Executing outside of the WordPress context.' );

// Enable HPOS compatibility.
add_action( 'before_woocommerce_init', function() {
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
}
} );

// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
require_once __DIR__ . '/src/class-drip-woocommerce-settings.php';
Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Contributors: getdrip
Tags: ecommerce, emailmarketing, marketingautomation, emailmarketingautomation, woocommerce, drip
Requires at least: 4.6
Tested up to: 6.0.3
Stable tag: 1.1.3
Tested up to: 6.2.2
Stable tag: 1.1.4
Requires PHP: 5.6
License: GPLv2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -74,6 +74,10 @@ The philosophy behind this plugin is to do as little as possible in it, and as m

* Your change here!

= 1.1.4 =

* HPOS Compatible for new WooCommerce versions

= 1.1.3 =

* Fix a bug that caused an error when viewing a product with an empty price
Expand Down

0 comments on commit 50e6436

Please sign in to comment.