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

PLUG-2874 woocommerce checkout 360 #578

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion includes/api/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function initCartCommon()

}

add_action('setup_extra_setting_fields', 'addMagicCheckoutSettingFields');
add_action('setup_extra_setting_fields_1cc', 'addMagicCheckoutSettingFields');

function addMagicCheckoutSettingFields(&$defaultFormFields)
{
Expand Down
52 changes: 28 additions & 24 deletions includes/razorpay-affordability-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -526,37 +526,41 @@ function updateAffordabilityWidgetSettings()
woocommerce_update_options(getAffordabilityWidgetSettings());
try
{
if (isset($_POST['woocommerce_razorpay_key_id']) and
empty($_POST['woocommerce_razorpay_key_id']) === false and
isset($_POST['woocommerce_razorpay_key_secret']) and
empty($_POST['woocommerce_razorpay_key_secret']) === false)
{
$api = new Api($_POST['woocommerce_razorpay_key_id'], $_POST['woocommerce_razorpay_key_secret']);
}
else
$checkout360status = (get_option('rzp_checkout360_status') === 'yes') ? true : false;

if ($checkout360status === false)
{
$api = new Api(get_option('woocommerce_razorpay_settings')['key_id'],get_option('woocommerce_razorpay_settings')['key_secret']);
}
if (isset($_POST['woocommerce_razorpay_key_id']) and
empty($_POST['woocommerce_razorpay_key_id']) === false and
isset($_POST['woocommerce_razorpay_key_secret']) and
empty($_POST['woocommerce_razorpay_key_secret']) === false)
{
$api = new Api($_POST['woocommerce_razorpay_key_id'], $_POST['woocommerce_razorpay_key_secret']);
}
else
{
$api = new Api(get_option('woocommerce_razorpay_settings')['key_id'],get_option('woocommerce_razorpay_settings')['key_secret']);
}

$merchantPreferences = $api->request->request('GET', 'accounts/me/features');
$merchantPreferences = $api->request->request('GET', 'accounts/me/features');

if (isset($merchantPreferences) === false or
isset($merchantPreferences['assigned_features']) === false)
{
throw new Exception("Error in Api call.");
}
if (isset($merchantPreferences) === false or
isset($merchantPreferences['assigned_features']) === false)
{
throw new Exception("Error in Api call.");
}

update_option('rzp_afd_enable', 'no');
foreach ($merchantPreferences['assigned_features'] as $preference)
{
if ($preference['name'] === 'affordability_widget' or
$preference['name'] === 'affordability_widget_set')
update_option('rzp_afd_enable', 'no');
foreach ($merchantPreferences['assigned_features'] as $preference)
{
update_option('rzp_afd_enable', 'yes');
break;
if ($preference['name'] === 'affordability_widget' or
$preference['name'] === 'affordability_widget_set')
{
update_option('rzp_afd_enable', 'yes');
break;
}
}
}

}
catch (\Exception $e)
{
Expand Down
Loading
Loading