Skip to content

Commit

Permalink
Merge pull request #54 from newfold-labs/feature/bluehost-india-support
Browse files Browse the repository at this point in the history
Bluehost India Support
  • Loading branch information
ashrithapradeep authored Mar 8, 2023
2 parents fdb116d + fb86738 commit 4bf640e
Show file tree
Hide file tree
Showing 26 changed files with 696 additions and 94 deletions.
6 changes: 5 additions & 1 deletion atoms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
color: currentColor;
font: 400 18px var(--nfd-ecommerce-font-primary);
}
a {
color: var(--nfd-ecommerce-accent-primary);
text-decoration: none;
}
.nfd-ecommerce-loader-mini {
width: 1em;
height: 1em;
margin: 0;
}
.nfd-ecommerce-loader-inverse {
background: linear-gradient(to right, #f1f5f7 5%, rgba(0,0,0,0) 32%);
background: linear-gradient(to right, #f1f5f7 5%, rgba(0, 0, 0, 0) 32%);
&:before {
background: #f1f5f7;
}
Expand Down
2 changes: 1 addition & 1 deletion build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '8b69f94ca7bf0d2ddc2f');
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'c737810d340adc0b0f21');
62 changes: 62 additions & 0 deletions includes/Data/Brands.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
namespace NewfoldLabs\WP\Module\ECommerce\Data;
/**
* Contains Brand information.
*/
final class Brands {
/**
* Brand specific data - Bluehost, Bluhost India
*
* @return array
*/
public static function get_brands() {

return array(
'crazy-domains' => array(
'brand' => 'crazy-domains',
'name' => 'CrazyDomains',
'url' => 'https://crazydomains.com',
'hireExpertsInfo' => 'admin.php?page=crazy-domains#/marketplace/services/blue-sky',
'adminPage' => 'admin.php?page=crazy-domains',
'setup' => array(
'payment' => array('Paypal'),
'shipping' => array('Shippo'),
),
'defaultContact' => array(
'woocommerce_default_country' => 'AU:NSW',
'woocommerce_currency' => 'AUD',
),
),
'bluehost' => array(
'brand' => 'bluehost',
'name' => 'Bluehost',
'url' => 'https://bluehost.com',
'hireExpertsInfo' => 'admin.php?page=bluehost#/marketplace/services/blue-sky',
'adminPage' => 'admin.php?page=bluehost',
'setup' => array(
'payment' => array('Paypal'),
'shipping' => array('Shippo'),
),
'defaultContact' => array(
'woocommerce_default_country' => 'US:AZ',
'woocommerce_currency' => 'USD',
),
),
'bluehost-india' => array(
'brand' => 'bluehost-india',
'name' => 'Bluehost',
'url' => 'https://bluehost.in',
'hireExpertsInfo' => 'https://www.bluehost.in/solutions/full-service',
'adminPage' => 'admin.php?page=bluehost',
'setup' => array(
'payment' => array('Razorpay'),
'shipping' => array(),
),
'defaultContact' => array(
'woocommerce_default_country' => 'IN:AP',
'woocommerce_currency' => 'INR',
),
),
);
}
}
1 change: 1 addition & 0 deletions includes/Data/Plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public static function get_slug_map( $plugin ) {
'yith_shippo_shipping_for_woocommerce' => array( 'https://hiive.cloud/workers/plugin-downloads/yith-shippo-shippings-for-woocommerce', 'yith-shippo-shippings-for-woocommerce-extended/init.php' ),
'yith_paypal_payments' => array( 'https://hiive.cloud/workers/plugin-downloads/yith-paypal-payments-for-woocommerce', 'yith-paypal-payments-for-woocommerce-extended/init.php' ),
'woocommerce' => array( 'ignore', 'woocommerce/woocommerce.php' ),
'woo_razorpay' => array( 'ignore', 'woo-razorpay/woo-razorpay.php' ),
);
if ( in_array( $plugin, array_keys( $map ) ) ) {
$plugin = $map[ $plugin ];
Expand Down
1 change: 1 addition & 0 deletions includes/ECommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ECommerce {
protected $options = array(
'nfd-ecommerce-captive-flow-paypal',
'nfd-ecommerce-captive-flow-shippo',
'nfd-ecommerce-captive-flow-razorpay',
'nfd-ecommerce-onboarding-check',
'nfd-ecommerce-counter',
'woocommerce_store_address',
Expand Down
59 changes: 53 additions & 6 deletions includes/Partials/CaptiveFlow.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,57 @@

class CaptiveFlow {

static $PAYPAL_CAPTIVE_FLOW = 'nfd-ecommerce-captive-flow-paypal';
static $SHIPPO_CAPTIVE_FLOW = 'nfd-ecommerce-captive-flow-shippo';
static $RAZORPAY_CAPTIVE_FLOW = 'nfd-ecommerce-captive-flow-razorpay';

public static function init() {
add_action( 'admin_menu', array( __CLASS__, 'register_page' ) );
add_action( 'load-admin_page_' . 'nfd-ecommerce-captive-flow-paypal', array( __CLASS__, 'enqueue_styles' ), 100 );
add_action( 'load-admin_page_' . 'nfd-ecommerce-captive-flow-shippo', array( __CLASS__, 'enqueue_styles' ), 100 );
add_action( 'rest_api_init', array( __CLASS__, 'register_options' ) );
add_action( 'load-admin_page_' . self::$PAYPAL_CAPTIVE_FLOW, array( __CLASS__, 'enqueue_styles' ), 100 );
add_action( 'load-admin_page_' . self::$SHIPPO_CAPTIVE_FLOW, array( __CLASS__, 'enqueue_styles' ), 100 );
}

public static function register_options() {
\register_setting(
'general',
'woocommerce_razorpay_settings',
array(
'show_in_rest' => array(
'schema' => array(
'type' => 'object',
'properties' => array(
'enabled' => array(
'type' => 'string',
),
'title' => array(
'type' => 'string',
),
'description' => array(
'type' => 'string',
),
'key_id' => array(
'type' => 'string',
),
'key_secret' => array(
'type' => 'string',
),
'payment_action' => array(
'type' => 'string',
),
'order_success_message' => array(
'type' => 'string',
),
'enable_1cc_debug_mode' => array(
'type' => 'string',
),
),
),
),
'type' => 'object',
'description' => __( 'NFD eCommerce RazorPay Options', 'wp-module-ecommerce' ),
)
);
}

public static function enqueue_styles() {
Expand All @@ -27,7 +74,7 @@ public static function register_page() {
null,
null,
Permissions::ADMIN,
'nfd-ecommerce-captive-flow-paypal',
self::$PAYPAL_CAPTIVE_FLOW,
array( __CLASS__, 'render_paypal' ),
100
);
Expand All @@ -36,7 +83,7 @@ public static function register_page() {
null,
null,
Permissions::ADMIN,
'nfd-ecommerce-captive-flow-shippo',
self::$SHIPPO_CAPTIVE_FLOW,
array( __CLASS__, 'render_shippo' ),
100
);
Expand All @@ -45,15 +92,15 @@ public static function register_page() {
public static function render_paypal() {
echo PHP_EOL;
echo '<div id="nfd-ecommerce" class="nfd-ecommerce-captive-flow">';
echo do_action( 'nfd-ecommerce-captive-flow-paypal' );
echo do_action( self::$PAYPAL_CAPTIVE_FLOW );
echo '</div>';
echo PHP_EOL;
}

public static function render_shippo() {
echo PHP_EOL;
echo '<div id="nfd-ecommerce" class="nfd-ecommerce-captive-flow">';
echo do_action( 'nfd-ecommerce-captive-flow-shippo' );
echo do_action( self::$SHIPPO_CAPTIVE_FLOW );
echo '</div>';
echo PHP_EOL;
}
Expand Down
1 change: 1 addition & 0 deletions includes/RestApi/PluginsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function get_plugins_status() {
'yith_wcas_panel',
'yith_paypal_payments',
'yith_shippo_shipping_for_woocommerce',
'woo_razorpay'
);
foreach ( $plugins as $plugin ) {
$map = Plugins::get_slug_map( $plugin );
Expand Down
15 changes: 10 additions & 5 deletions includes/RestApi/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use NewfoldLabs\WP\Module\ECommerce\Permissions;
use function NewfoldLabs\WP\ModuleLoader\container;
use NewfoldLabs\WP\Module\Onboarding\Data\Data;
use NewfoldLabs\WP\Module\ECommerce\Data\Brands;

class UserController {

Expand Down Expand Up @@ -34,21 +35,25 @@ public function get_page_status() {
);
$pages = \get_pages( $args );
$theme = \wp_get_theme();
$brand = 'newfold';
$brand_raw_value = \get_option('mm_brand', 'newfold' );
$brand = \sanitize_title_with_dashes( strtolower( str_replace( '_', '-', $brand_raw_value ) ) );
$customer = array(
plan_subtype => 'wc_premium'
'plan_subtype' => 'unknown'
);
$brands = Brands::get_brands();
$currentBrandConfig = $brands[$brand];
if (class_exists('NewfoldLabs\WP\Module\Onboarding\Data\Data')) {
$brand_details = Data::current_brand();
$brand = $brand_details['brand'];
$customer_from_options = Data::customer_data();
if ($customer_from_options != false) {
$customer = $customer_from_options;
}
}
return array(
'site' => array (
'url' => \get_site_url()
),
'details' => $customer,
'brand' => $brand,
'currentBrandConfig' => $currentBrandConfig,
'theme' => array(
'manage' => Permissions::rest_can_manage_themes(),
'template' => $theme->get_template(),
Expand Down
12 changes: 12 additions & 0 deletions modals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,15 @@
text-decoration: none;
}
}

form.nfd-ecommerce-modal-razorpay {
display: grid;
padding: 40px 40px 0.3em;
gap: 1.5em;
@media screen and (max-width: 481px) {
padding: 40px 1em 0.3em;
.razorpay-logo {
justify-self: center;
}
}
}
Loading

0 comments on commit 4bf640e

Please sign in to comment.