Skip to content

Commit

Permalink
Merge pull request #405 from Invizo/develop
Browse files Browse the repository at this point in the history
Merge develop with master
  • Loading branch information
code-with-mehedi authored Apr 23, 2024
2 parents 5ff928a + ab1b870 commit e284e0a
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SLUG: storegrowth-sales-booster
VERSION: 1.27.8
VERSION: 1.28.8
3 changes: 0 additions & 3 deletions Includes/Modules/CountdownTimer/Includes/EnqueueScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ private function __construct() {
* Enqueue CSS and JS for fly cart.
*/
public function wp_enqueue_scripts() {
if ( ! is_product() && ! is_shop() ) {
return;
}

wp_enqueue_style(
'sgsb-cd-timer-custom-style',
Expand Down
12 changes: 6 additions & 6 deletions Includes/Modules/UpsellOrderBump/Includes/Ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ public function upsell_offer_product_add_to_cart() {
$all_cart_product_ids[] = $value['product_id'];
}

$bump_price = isset( $_POST['data']['bump_price'] ) ? floatval( wp_unslash( $_POST['data']['bump_price'] ) ) : null;
$checked = isset( $_POST['data']['checked'] ) ? boolval( wp_unslash( $_POST['data']['checked'] ) ) : null;
$offer_product_id = isset( $_POST['data']['offer_product_id'] ) ? intval( wp_unslash( $_POST['data']['offer_product_id'] ) ) : null;

$bump_price = isset( $_POST['data']['bump_price'] ) ? floatval( wp_unslash( $_POST['data']['bump_price'] ) ) : null;
$checked = isset( $_POST['data']['checked'] ) ? boolval( wp_unslash( $_POST['data']['checked'] ) ) : null;
$offer_product_id = isset( $_POST['data']['offer_product_id'] ) ? intval( wp_unslash( $_POST['data']['offer_product_id'] ) ) : null;
$offer_variation_id = isset( $_POST['data']['offer_variation_id'] ) ? intval( wp_unslash( $_POST['data']['offer_variation_id'] ) ) : null;
if ( $checked ) {
$product_id = $offer_product_id;
$product_cart_id = WC()->cart->generate_cart_id( $product_id );
Expand All @@ -144,7 +144,7 @@ public function upsell_offer_product_add_to_cart() {
// Cart item data to send & save in order.
$cart_item_data = array( 'custom_price' => $custom_price );
// Woocommerce function to add product into cart check its documentation also.
$woocommerce->cart->add_to_cart( $offer_product_id, 1, $variation_id = 0, $variation = array(), $cart_item_data );
$woocommerce->cart->add_to_cart( $offer_product_id, 1, $offer_variation_id, $variation = array(), $cart_item_data );
// Calculate totals.
$woocommerce->cart->calculate_totals();
// Save cart to session.
Expand All @@ -154,7 +154,7 @@ public function upsell_offer_product_add_to_cart() {

}

wp_send_json_success('Product added to cart successfully.');
wp_send_json_success( $offer_variation_id );
die();
}

Expand Down
76 changes: 59 additions & 17 deletions Includes/Modules/UpsellOrderBump/Includes/EnqueueScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ public function admin_enqueue_styles() {
* Style for frontend.
*/
public function front_styles() {
if ( ! is_checkout() ) {
return;
}
if ( ! is_checkout() ) {
return;
}

$ftime = filemtime( sgsb_modules_path( 'UpsellOrderBump/assets/css/order-bump-front.css' ) );

Expand Down Expand Up @@ -169,20 +169,20 @@ public function prodcut_list() {
$simple_product_for_offer = array();

foreach ( $products as $product ) {
// Get the product category IDs.
$category_ids = wp_get_post_terms( $product->ID, 'product_cat', array( 'fields' => 'ids' ) );
// Get the product category IDs.
$category_ids = wp_get_post_terms( $product->ID, 'product_cat', array( 'fields' => 'ids' ) );
$product_list_for_select[] = array(
'value' => $product->ID,
'label' => $product->post_title,
'catIds' => $category_ids,
'catIds' => $category_ids,
);

$_product = wc_get_product( $product->ID );
$sale_price = $_product->get_sale_price();
$regular_price = $_product->get_regular_price();

// Prepare woocommerce price data.
$price = ! empty( $sale_price ) ? esc_html( $sale_price ) : esc_html( $regular_price );
$price = esc_html( $regular_price );
$price = wp_strip_all_tags( html_entity_decode( wc_price( $price ) ) );

// Render woocommerce price with currency symbol.
Expand All @@ -201,7 +201,7 @@ public function prodcut_list() {
// Get categories csv.
$category_names = implode( ', ', $category_names );

if ( $regular_price ) {
if ( $_product->is_type( 'simple' ) && $regular_price ) {
$simple_product_for_offer[] = array(
'price' => $price,
'value' => $product->ID,
Expand All @@ -210,35 +210,77 @@ public function prodcut_list() {
'label' => $product->post_title . $_product_price,
);
}
if ( $_product->is_type( 'variable' ) ) {
$variations = $_product->get_available_variations();

foreach ( $variations as $variation ) {
$variation_id = $variation['variation_id'];
$variation_attributes = $variation['attributes'];
$regular_price = number_format( $variation['display_regular_price'], 2 ) . $currency_symbol;
$variation_root_name = $_product->get_title();
$variation_name = $variation_root_name . '(' . implode( ', ', $variation_attributes ) . ') (' . $regular_price . ')';

$simple_product_for_offer[] = array(
'price' => $regular_price,
'value' => $variation_id,
'currency' => $currency_symbol,
'offer_categories' => $category_names,
'label' => $variation_name,
);
}
}

$product_title_by_id[ $product->ID ] = $product->post_title;
}

$product_info['productListForSelect'] = $product_list_for_select;
$product_info['simpleProductForOffer'] = $simple_product_for_offer;
$product_info['productTitleById'] = $product_title_by_id;

return $product_info;
}

/**
* Product list for view.
*/
public function prodcut_list_for_view() {
$args = array(
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
);
$products = get_posts( $args );
$product_list_for_view = array();
$products = get_posts( $args );

$product_list_for_view = array();
foreach ( $products as $product ) {
$_product = wc_get_product( $product->ID );
$product->regular_price = $_product->get_regular_price();
$product->image_url = wp_get_attachment_url( get_post_thumbnail_id( $product->ID ), 'thumbnail' );
$product_list_for_view[ $product->ID ] = $product;
$_product = wc_get_product( $product->ID );

if ( $_product->is_type( 'simple' ) ) {
$product_list_for_view[ $product->ID ] = array(
'ID' => $product->ID,
'post_title' => $_product->get_title(),
'image_url' => wp_get_attachment_url( get_post_thumbnail_id( $product->ID ), 'thumbnail' ),
'regular_price' => number_format( (int) $_product->get_regular_price(), 2 ),
);
}
if ( $_product->is_type( 'variable' ) ) {
$variations = $_product->get_available_variations();

foreach ( $variations as $variation ) {
$variation_id = $variation['variation_id'];
$variation_attributes = $variation['attributes'];
$regular_price = number_format( $variation['display_regular_price'], 2 );
$variation_root_name = $_product->get_title();
$variation_name = $variation_root_name . '(' . implode( ', ', $variation_attributes ) . ')';
$image_url = $variation['image']['url'];

$product_list_for_view[ $variation_id ] = array(
'ID' => $variation_id,
'post_title' => $variation_name,
'image_url' => $image_url,
'regular_price' => $regular_price,
);
}
}
}

return $product_list_for_view;
}

Expand Down
37 changes: 18 additions & 19 deletions Includes/Modules/UpsellOrderBump/Includes/OrderBump.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,22 @@ public function __construct() {
public function bump_product_frontend_view() {

global $woocommerce;
$all_cart_products = $woocommerce->cart->get_cart();
$all_cart_product_ids = array();
$all_cart_category_ids = array();
$args_bump = array(
$all_cart_products = $woocommerce->cart->get_cart();
$all_cart_product_ids = array();
$all_cart_category_ids = array();
$args_bump = array(
'post_type' => 'sgsb_order_bump',
'posts_per_page' => -1,
);
$bump_list = get_posts( $args_bump );
$bump_list = get_posts( $args_bump );

foreach ( $all_cart_products as $value ) {
$cat_ids = $value['data']->get_category_ids();
foreach ( $cat_ids as $cat_id ) {
$all_cart_category_ids[] = $cat_id;
}
$all_cart_product_ids[] = $value['product_id'];
$all_cart_product_ids[] = $value['variation_id'] === 0 ? $value['product_id'] : $value['variation_id'];
}

foreach ( $bump_list as $bump ) {
$bump_info = maybe_unserialize( $bump->post_excerpt );
$bump_info = (object) $bump_info;
Expand Down Expand Up @@ -91,18 +90,18 @@ public function bump_product_frontend_view() {
continue;
}

$bump_type = ! empty( $bump_info->bump_type ) ? esc_html( $bump_info->bump_type ) : 'products';
if ( $bump_type === 'products' ) {
$target_products = ! empty( $bump_info->target_products ) ? wc_clean( $bump_info->target_products ) : array();
if ( $target_products && ( count( $all_cart_product_ids ) !== count( array_diff( $all_cart_product_ids, $target_products ) ) ) ) {
include __DIR__ . '/../templates/bump-product-front-view.php';
}
} else {
$target_categories = ! empty( $bump_info->target_categories ) ? wc_clean( $bump_info->target_categories ) : array();
if ( $target_categories && ( count( $all_cart_category_ids ) !== count( array_diff( $all_cart_category_ids, $target_categories ) ) ) ) {
include __DIR__ . '/../templates/bump-product-front-view.php';
}
}
$bump_type = ! empty( $bump_info->bump_type ) ? esc_html( $bump_info->bump_type ) : 'products';
if ( $bump_type === 'products' ) {
$target_products = ! empty( $bump_info->target_products ) ? wc_clean( $bump_info->target_products ) : array();
if ( $target_products && ( count( $all_cart_product_ids ) !== count( array_diff( $all_cart_product_ids, $target_products ) ) ) ) {
include __DIR__ . '/../templates/bump-product-front-view.php';
}
} else {
$target_categories = ! empty( $bump_info->target_categories ) ? wc_clean( $bump_info->target_categories ) : array();
if ( $target_categories && ( count( $all_cart_category_ids ) !== count( array_diff( $all_cart_category_ids, $target_categories ) ) ) ) {
include __DIR__ . '/../templates/bump-product-front-view.php';
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
function extraProducts(product_id, check_status, offer_price) {
function extraProducts(product_id, variation_id , check_status, offer_price) {

var $ = jQuery;
var passData = {
offer_product_id : product_id,
offer_variation_id : variation_id,
checked : check_status,
bump_price : offer_price

Expand All @@ -12,6 +13,6 @@ function extraProducts(product_id, check_status, offer_price) {
'data' : passData,
'_ajax_nonce' : bump_save_url.ajd_nonce
}, function (data) {
location.reload();
// location.reload();
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
*
* @package Bump design for front.
*/

if ( $_product && $_product->is_type( 'variation' ) ) {
$product_offer_id = $_product->get_parent_id();
$variation_id = $offer_product_id;
} elseif ( $_product && $_product->is_type( 'simple' ) ) {
$product_offer_id = $offer_product_id;
$variation_id = 0;
} else {
return;
}

?>

<div class='template-overview-area'>
Expand Down Expand Up @@ -83,12 +94,12 @@
<input
type = "checkbox"
class = 'custom-checkbox'
value = "<?php echo esc_attr( $offer_product_id ); ?>"
id = "test_<?php echo esc_attr( $offer_product_id ); ?>"
onchange = "extraProducts(<?php echo esc_attr( $offer_product_id ); ?>,'<?php echo esc_attr( $checked ); ?>', '<?php echo esc_attr( $offer_price ); ?>')"
value = "<?php echo esc_attr( $product_offer_id ); ?>"
id = "test_<?php echo esc_attr( $product_offer_id ); ?>"
onchange = "extraProducts(<?php echo esc_attr( $product_offer_id ); ?>,<?php echo esc_attr( $variation_id ); ?>,'<?php echo esc_attr( $checked ); ?>', '<?php echo esc_attr( $offer_price ); ?>')"
<?php echo esc_attr( $checked ); ?>
/>
<label for='test_<?php echo esc_attr( $offer_product_id ); ?>'>
<label for='test_<?php echo esc_attr( $product_offer_id ); ?>'>
<?php esc_html_e( 'Select', 'storegrowth-sales-booster' ); ?>
</label>
</div>
Expand Down
15 changes: 10 additions & 5 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
=== StoreGrowth — Best WooCommerce Marketing Solution — Fly Cart, Direct Checkout, Add To Cart Redirect, BOGO, Quick View, Sales Countdown Timer, Floating Notification Bar, Live Sales Notifications, Upsell Order Bump & More to boost sales ===
Contributors: mehedi_csit, invizo
Tags: floating cart, fly cart, side cart, checkout optimization, notification bar, add to cart, Buy now button, woocommerce direct checkout, woocommerce ajax cart, cart popup, sales notification, social proof, fomo, woocommerce notification, Side cart, fly cart, upsell order bump, free shipping bar, stock count progress bar, sales countdown timer.
Tags: upsell, sliding cart, side cart, checkout optimization, notification bar, add to cart redirect, Buy now button, woocommerce direct checkout, woocommerce ajax cart, cart popup, sales notification, social proof, fomo, woocommerce notification, Side cart, fly cart, upsell order bump, free shipping bar, stock count progress bar, sales countdown timer.

Requires at least: 5.4
Tested up to: 6.4.1
Stable tag: 1.27.8
Stable tag: 1.28.8
Requires PHP: 7.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Boost Your Sales and Conversion with Fly Cart, Direct Checkout, Add To Cart Redirect, BOGO, Quick View, Sales Countdown Timer, Floating Notification Bar, Live Sales Notifications, Upsell Order Bump & Many More.
Boost Your Sales and Conversion with Upsell, FOMO, Buy one get one, Buy x get y, Fly Cart, Direct Checkout, Add To Cart Redirect, BOGO, Quick View, Sales Countdown Timer, Floating Notification Bar, Live Sales Notifications, Upsell Order Bump & Many More.

== Description ==

= Maximize your WooCommerce sales with powerful marketing modules such as fly cart, direct checkout, add to cart redirect, bogo, quikc view, upsell order bump, sales countdown, live sales notification, and many more! =

StoreGrowth is a conversion-boosting toolkit to help you optimize your sales campaigns for the best results. It offers you **10+ powerful marketing modules** in one place, so you don’t need to use multiple plugins to increase sales.
[StoreGrowth](https://storegrowth.io/) is a conversion-boosting toolkit to help you optimize your sales campaigns for the best results. It offers you **10+ powerful marketing modules** in one place, so you don’t need to use multiple plugins to increase sales.

- **It is lightweight and easy to use.**
- **It is standalone with no page builder dependency.**
Expand All @@ -28,7 +28,7 @@ StoreGrowth is specially built for WooCommerce marketers who are looking for a c

[youtube https://youtu.be/UPGtOEsY2kI?si=s-xfT5NNH5SP1Ya2]


👉<a href="https://demo.storegrowth.io/" target="_blank"> Demo </a>
👉<a href="https://storegrowth.io/documentation/" target="_blank"> Documentation </a>
👉 <a href="https://storegrowth.io/pricing/" target="_blank"> Upgrade To Pro </a>

Expand Down Expand Up @@ -267,6 +267,11 @@ StoreGrowth floating notification bar displays ongoing offers and discounts whil

== Changelog ==

= 1.28.8 - 23 April, 2024 =

fix: countdown timer script issue
enhance: add variable product support for upsell order bump

= 1.27.8 - 05 April, 2024 =

fix: order bump offer price
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "storegrowth-sales-booster",
"version": "1.27.8",
"version": "1.28.8",
"type": "module",
"description": "=== StoreGrowth - Sales Booster === Contributors: Invizo Tags: booster, sales booster, for woocommerce, fly cart, sales notification, upsell, order bump, cross sell, stock countdown, Quick View Requires at least: 5.4 Tested up to: 6.2.2 Stable tag: 1.0.0 Requires PHP: 7.4 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html",
"main": "index.js",
Expand Down
13 changes: 8 additions & 5 deletions storegrowth-sales-booster.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: StoreGrowth - Sales Booster For WooCommerce Lite
* Description: Best WooCommerce Direct Checkout, Fly Cart, BOGO, Quick View, Live Sales Notifications, Floating Notification Bar and More Essential Features for Every WooCommerce Site!
* Version: 1.27.8
* Version: 1.28.8
* Author: Invizo
* Author URI: https://invizo.io/
* License: GPL-2.0+
Expand Down Expand Up @@ -51,7 +51,7 @@
* Define The Template's Folder Constant
*/
if ( ! defined( 'STOREGROWTH_PLUGIN_TEMPLATES_PATH_LITE' ) ) {
define( 'STOREGROWTH_PLUGIN_TEMPLATES_PATH_LITE', plugin_dir_path(STOREGROWTH_PLUGIN_FILE) . 'Includes/Modules/');
define( 'STOREGROWTH_PLUGIN_TEMPLATES_PATH_LITE', plugin_dir_path( STOREGROWTH_PLUGIN_FILE ) . 'Includes/Modules/' );
}

/**
Expand Down Expand Up @@ -108,9 +108,12 @@ function () {
/**
* add option when plugin is activated.
*/
register_activation_hook(__FILE__, function () {
add_option('storegrowth_activation_redirect', true);
});
register_activation_hook(
__FILE__,
function () {
add_option( 'storegrowth_activation_redirect', true );
}
);
/**
* Initialize the plugin functionality.
*
Expand Down

0 comments on commit e284e0a

Please sign in to comment.