-
diff --git a/Includes/Modules/DirectCheckout/assets/src/helper.js b/Includes/Modules/DirectCheckout/assets/src/helper.js
index 20d09c8b..cc649144 100644
--- a/Includes/Modules/DirectCheckout/assets/src/helper.js
+++ b/Includes/Modules/DirectCheckout/assets/src/helper.js
@@ -1,14 +1,21 @@
import { __ } from '@wordpress/i18n';
export const createDirectCheckoutForm = {
- buy_now_button_setting: __( 'cart-with-buy-now', 'storegrowth-sales-booster' ),
- buy_now_button_label: __( 'Buy Now', 'storegrowth-sales-booster' ),
- checkout_redirect: 'legacy-checkout',
- shop_page_checkout_enable: true,
- product_page_checkout_enable: true,
- button_color: "#008dff",
- text_color: "#ffffff",
- font_size: 16,
- button_border_radius: 5,
- generated_link:"example",
+ font_size : 16,
+ text_color : "#ffffff",
+ font_family : "poppins",
+ button_style : true,
+ button_color : "#008dff",
+ border_color : "#008dff",
+ border_width : 1,
+ paddingXaxis : 20,
+ paddingYaxis : 10,
+ generated_link : "example",
+ checkout_redirect : 'legacy-checkout',
+ button_border_style : "solid",
+ button_border_radius : 5,
+ buy_now_button_label : __( 'Buy Now', 'storegrowth-sales-booster' ),
+ buy_now_button_setting : __( 'cart-with-buy-now', 'storegrowth-sales-booster' ),
+ shop_page_checkout_enable : true,
+ product_page_checkout_enable : true,
};
diff --git a/Includes/Modules/ProgressiveDiscountBanner/Includes/EnqueueScript.php b/Includes/Modules/ProgressiveDiscountBanner/Includes/EnqueueScript.php
index 7a0e9d3e..9117deac 100644
--- a/Includes/Modules/ProgressiveDiscountBanner/Includes/EnqueueScript.php
+++ b/Includes/Modules/ProgressiveDiscountBanner/Includes/EnqueueScript.php
@@ -81,6 +81,11 @@ public function admin_enqueue_scripts( $hook ) {
$settings_file['version'],
false
);
+
+ // Pass the Cart URL to the JavaScript file
+ wp_localize_script('sgsb-pd-banner-settings', 'sgsbFsbData', array(
+ 'cartUrl' => wc_get_cart_url(), // WooCommerce Cart URL
+ ));
}
}
diff --git a/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/DesignTab.js b/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/DesignTab.js
index 1dd88277..7de427a1 100644
--- a/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/DesignTab.js
+++ b/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/DesignTab.js
@@ -11,6 +11,7 @@ import Templates from './Templates';
function DesignTab(props) {
const {
+ isValid,
formData,
setFormData,
onFieldChange,
@@ -18,6 +19,8 @@ function DesignTab(props) {
buttonLoading,
fontFamily,
onFormReset,
+ undoHandler,
+ showUndoIcon
} = props;
return (
@@ -50,41 +53,75 @@ function DesignTab(props) {
) }
+ { Boolean( formData.btn_style ) && (
+
+
+
+
+ ) }
-
+
);
diff --git a/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/DiscountBanner.js b/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/DiscountBanner.js
index 0b927e78..d4acbf9b 100644
--- a/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/DiscountBanner.js
+++ b/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/DiscountBanner.js
@@ -1,5 +1,6 @@
import { Fragment } from "react";
import { __ } from "@wordpress/i18n";
+import { useState } from "@wordpress/element";
import { applyFilters } from '@wordpress/hooks';
import SelectBox from "../../../../../../assets/src/components/settings/Panels/PanelSettings/Fields/SelectBox";
import Number from "../../../../../../assets/src/components/settings/Panels/PanelSettings/Fields/Number";
@@ -7,9 +8,11 @@ import TextAreaBox from "../../../../../../assets/src/components/settings/Panels
import SettingsSection from "../../../../../../assets/src/components/settings/Panels/PanelSettings/SettingsSection";
import BarIcon from "./BarIcon";
import SettingInstruction from "./SettingInstruction";
+import Switcher from "sales-booster/src/components/settings/Panels/PanelSettings/Fields/Switcher";
+import TextInput from "sales-booster/src/components/settings/Panels/PanelSettings/Fields/TextInput";
function DiscountBanner(props) {
- const { formData, setFormData, onFieldChange } = props;
+ const { isValid, formData, setFormData, setShowUndo, onFieldChange } = props;
const barTypes = [
{
@@ -57,13 +60,13 @@ function DiscountBanner(props) {
{ key: iconStyleName, value:
}
) );
-
const onBarChange = ( key, value ) => {
setFormData( {
...formData,
[ key ]: value,
progressive_banner_custom_icon : '',
} );
+ setShowUndo( true );
};
return (
@@ -180,6 +183,50 @@ function DiscountBanner(props) {
"storegrowth-sales-booster"
)}
/>
+
+
+
+ { Boolean( formData.btn_style ) && (
+
+
+
+
+ ) }
{ applyFilters(
diff --git a/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/FreeShippingBarLayout.js b/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/FreeShippingBarLayout.js
index ec5c1ec4..93922ddf 100644
--- a/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/FreeShippingBarLayout.js
+++ b/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/FreeShippingBarLayout.js
@@ -24,17 +24,22 @@ function FreeShippingBarLayout({ outlet: Outlet, navigate, useSearchParams , mod
let [searchParams, setSearchParams] = useSearchParams("general");
const tabName = searchParams.get("tab_name") || "general";
const initialShipData = {
+ btn_text : 'Cart',
bar_type : "normal",
user_type : "both",
font_size : 20,
+ btn_style : true,
+ btn_color : "#ffffff",
text_color : "#ffffff",
icon_color : "#ffffff",
+ btn_target : sgsbFsbData?.cartUrl,
font_family : "poppins",
banner_delay : 7,
bar_position : "top",
bar_template : 'shipping_bar_one',
discount_type : "free-shipping",
banner_height : 60,
+ btn_text_color : "#073b4c",
banner_trigger : "after-few-seconds",
close_icon_color : "#ffffff",
background_color : "#0875FF",
@@ -55,6 +60,7 @@ function FreeShippingBarLayout({ outlet: Outlet, navigate, useSearchParams , mod
const onFormReset = () => {
setFormData({ ...initialShipData });
+ setShowUndo( false );
};
const fontFamily = [
@@ -97,6 +103,7 @@ function FreeShippingBarLayout({ outlet: Outlet, navigate, useSearchParams , mod
.success((response) => {
if (response.success && response.data) {
setFormData({ ...formData, ...response.data });
+ setUndoData({ ...undoData, ...response.data });
setTimeout(() => setPageLoading(false), 500);
}
});
@@ -106,12 +113,68 @@ function FreeShippingBarLayout({ outlet: Outlet, navigate, useSearchParams , mod
getSettings();
}, []);
+ const [ isValidUrl, setIsValidUrl ] = useState( true );
+
+ const validateURL = ( input ) => {
+ const pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol
+ '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name
+ '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address
+ '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path
+ '(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string
+ '(\\#[-a-z\\d_]*)?$','i'); // fragment locator
+ return !!pattern.test( input );
+ };
+
+ const [showUndo, setShowUndo] = useState({
+ btn_color : false,
+ text_color : false,
+ icon_color : false,
+ btn_text_color : false,
+ close_icon_color : false,
+ background_color : false,
+ });
+
+ const [undoData, setUndoData] = useState({
+ ...initialShipData,
+ });
+
+ const colorKeyStack = [
+ 'btn_color',
+ 'text_color',
+ 'icon_color',
+ 'btn_text_color',
+ 'close_icon_color',
+ 'background_color'
+ ];
+
const onFieldChange = (key, value) => {
+ if ( key === 'btn_target' ) {
+ setIsValidUrl( validateURL( value ) );
+ }
+
setFormData({
...formData,
[key]: value,
});
+
+ if ( colorKeyStack?.includes( key ) ) {
+ setShowUndo({ ...showUndo, [key]: true });
+ }
};
+
+ const onUndoClick = ( key ) => {
+ if ( colorKeyStack?.includes( key ) ) {
+ setShowUndo({
+ ...showUndo,
+ [key]: false,
+ });
+ setFormData({
+ ...formData,
+ [key]: undoData?.[key],
+ });
+ }
+ };
+
const changeTab = (key) => {
navigate("/progressive-discount-banner?tab_name=" + key);
};
@@ -148,8 +211,10 @@ function FreeShippingBarLayout({ outlet: Outlet, navigate, useSearchParams , mod
data,
})
.success(() => {
+ setShowUndo(false);
setButtonLoading(false);
notificationMessage(type);
+ setUndoData({ ...formData });
});
};
@@ -160,7 +225,9 @@ function FreeShippingBarLayout({ outlet: Outlet, navigate, useSearchParams , mod
panel: (
onFormSave("banner_settings")}
buttonLoading={buttonLoading}
@@ -173,7 +240,10 @@ function FreeShippingBarLayout({ outlet: Outlet, navigate, useSearchParams , mod
title: __("Design", "storegrowth-sales-booster"),
panel: (
onFormSave("design")}
@@ -195,10 +265,12 @@ function FreeShippingBarLayout({ outlet: Outlet, navigate, useSearchParams , mod
{showPreview && tabName && (
diff --git a/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/Preview.js b/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/Preview.js
index b69fd311..9e57907f 100644
--- a/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/Preview.js
+++ b/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/Preview.js
@@ -1,6 +1,7 @@
import React from 'react';
import BarIcon from "./BarIcon";
import {__} from "@wordpress/i18n";
+import {extractedTitle} from "sales-booster/src/utils/helper";
const Preview = ( { isProActive, formData, fontFamily } ) => {
const bannerStyle = {
@@ -59,8 +60,24 @@ const Preview = ( { isProActive, formData, fontFamily } ) => {
fontSize: formData.font_size,
}}
>
- {dynamicText}
+ { Boolean( formData.btn_style ) ? extractedTitle( dynamicText, 19 ) : dynamicText }
+ { Boolean( formData.btn_style ) && (
+
+ { extractedTitle( formData?.btn_text, 15 ) }
+
+ ) }
{
}}
onClick={() =>
window.open(
- "https://storegrowth.io/docs/free-shipping-bar/",
+ "https://storegrowth.io/docs/free-shipping-bar-setting/",
"_blank"
)
}
>
- Documentaion
+ Documentation
diff --git a/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/SettingsTab.js b/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/SettingsTab.js
index 3f71d143..3b3ededb 100644
--- a/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/SettingsTab.js
+++ b/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/SettingsTab.js
@@ -6,19 +6,23 @@ import {Fragment} from "react";
function SettingsTab(props) {
const {
+ isValid,
formData,
setFormData,
onFieldChange,
onFormSave,
buttonLoading,
- onFormReset
+ onFormReset,
+ setShowUndo
} = props;
return (
@@ -26,7 +30,7 @@ function SettingsTab(props) {
Note: Please clear your cart in order to see the updates when you update
diff --git a/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/Templates.js b/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/Templates.js
index 082cc2bb..fb2c6fd2 100644
--- a/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/Templates.js
+++ b/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/Templates.js
@@ -6,7 +6,7 @@ import ShippingBarOne from "./Templates/ShippingBarOne";
import {applyFilters} from "@wordpress/hooks";
import RadioTemplate from "sales-booster/src/components/settings/Panels/PanelSettings/Fields/RadioTemplate";
-const Templates = ( { formData, setFormData } ) => {
+const Templates = ( { formData, setFormData, showUndoIcon } ) => {
let templates = [
{ key: 'shipping_bar_one', component: },
];
@@ -19,12 +19,17 @@ const Templates = ( { formData, setFormData } ) => {
let templateStyles = {
shipping_bar_one: {
+ btn_text : __( 'Cart', 'storegrowth-sales-booster' ),
font_size : 20,
+ btn_style : true,
+ btn_color : "#ffffff",
text_color : "#ffffff",
icon_color : "#ffffff",
+ btn_target : sgsbFsbData?.cartUrl,
font_family : "poppins",
bar_template : 'shipping_bar_one',
banner_height : 60,
+ btn_text_color : "#073b4c",
close_icon_color : "#ffffff",
background_color : "#0875FF",
cart_minimum_amount : 10,
@@ -41,6 +46,10 @@ const Templates = ( { formData, setFormData } ) => {
);
const onTemplateChange = ( name, value ) => {
+ for ( let key in showUndoIcon ) {
+ showUndoIcon[key] = false;
+ }
+
setFormData( {
...formData,
...templateStyles?.[ value ]
diff --git a/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/Templates/ShippingBarOne.js b/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/Templates/ShippingBarOne.js
index 6c241896..47b8d797 100644
--- a/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/Templates/ShippingBarOne.js
+++ b/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/Templates/ShippingBarOne.js
@@ -1,5 +1,6 @@
import React from "react";
import { __ } from "@wordpress/i18n";
+import { extractedTitle } from "sales-booster/src/utils/helper";
const ShippingBarOne = () => {
return (
@@ -73,9 +74,23 @@ const ShippingBarOne = () => {
position : 'relative',
}}
>
- { __( 'Add more $10 to get FREE SHIPPING.', 'storegrowth-sales-booster' ) }
+ { __( 'Add more $10 to get...', 'storegrowth-sales-booster' ) }
+
+ { __( 'Cart', 'storegrowth-sales-booster' ) }
+