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

added multiple checkout option #251

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
21 changes: 21 additions & 0 deletions includes/api/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,27 @@ function addMagicCheckoutSettingFields(&$defaultFormFields)
'label' => __('Enable debug mode for Magic Checkout'),
'default' => 'yes',
),
'enable_dual_checkout_oncart' => array(
'title' => __('Activate Dual checkout on cart'),
'type' => 'checkbox',
'description' => "Activate Dual checkout on cart page",
'label' => __('Activate Dual checkout on cart'),
'default' => 'yes',
),
'enable_dual_checkout_onpdp' => array(
'title' => __('Activate Dual checkout on Buynow'),
'type' => 'checkbox',
'description' => "Activate Dual checkout on Product description Page",
'label' => __('Activate Dual checkout on Buynow'),
'default' => 'yes',
),
'enable_dual_checkout_minicart' => array(
'title' => __('Activate Dual checkout on minicart'),
'type' => 'checkbox',
'description' => 'Activate Dual checkout on minicart',
'label' => __('Activate Dual checkout on minicart'),
'default' => 'yes',
),
);

$defaultFormFields = array_merge($defaultFormFields, $magicCheckoutConfigFields);
Expand Down
24 changes: 24 additions & 0 deletions includes/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,30 @@ function isMiniCartCheckoutEnabled()
);
}

function isDualMiniCartCheckoutEnabled()
{
return (
empty(get_option('woocommerce_razorpay_settings')['enable_dual_checkout_minicart']) === false
&& 'yes' == get_option('woocommerce_razorpay_settings')['enable_dual_checkout_minicart']
);
}

function isDualPdpCheckoutEnabled()
{
return (
empty(get_option('woocommerce_razorpay_settings')['enable_dual_checkout_onpdp']) === false
&& 'yes' == get_option('woocommerce_razorpay_settings')['enable_dual_checkout_onpdp']
);
}

function isDualCartCheckoutEnabled()
{
return (
empty(get_option('woocommerce_razorpay_settings')['enable_dual_checkout_oncart']) === false
&& 'yes' == get_option('woocommerce_razorpay_settings')['enable_dual_checkout_oncart']
);
}

function validateInput($route, $param)
{
$failure_reason = null;
Expand Down
88 changes: 80 additions & 8 deletions public/css/1cc-product-checkout.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
#btn-1cc {
display: block !important;
width: 100%;
}
#btn-1cc-mini-cart {
display: block !important;
width: 100%;
}
#btn-1cc-pdp {
margin-left: 5px;
}
#rzp-spinner-backdrop {
position: fixed;
top: 0;
Expand Down Expand Up @@ -76,4 +69,83 @@
#rzp-logo {
height: 45px !important;
}
}
}
.button-1cc-wrapper {
display: flex;
font-size: 11px;
align-items: center;
justify-content: center;
}
.button-1cc-text {
padding-left: 5px;
color: #fff !important;
padding-top: 3px;
}
.btn-1cc-container {
background-image: linear-gradient(to right, #005BF2, #1E4C9C) !important;
margin-left: 5px;
color: white;
margin-top: 12px;
border-radius: 4px !important;
font-weight: bold;
margin: 0px;
}
.rzp-btn-icon {
display: flex;
justify-content: center;
padding: 5px 0px 10px
}
.btn-1cc-section {
display: flex;
flex-direction: column;
width: 100%;
align-items: center;
}
#btn-1cc-pdp {
display: flex;
align-items: center;
margin-left: 5px;
justify-content: center;
margin-bottom: 0px;
border: transparent;
padding: 10px 20px;
position: relative;
z-index: 1;
}
#btn-1cc-pdp:before {
content: '' !important;
margin: 0px;
}
#btn-1cc-pdp:after {
content: '' !important;
}
#btn-1cc:after {
content: '' !important;
}
#btn-1cc {
display: flex !important;
justify-content: center;
align-items: center;
width: 100%;
margin-bottom: 0px;
border: transparent;
}
#btn-1cc-mini-cart{
background: linear-gradient(to right, #005BF2, #1E4C9C) !important;
border: transparent;
margin-bottom: 0px;
}














28 changes: 28 additions & 0 deletions templates/rzp-dual-checkout-btn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

<div class="rzp-magic-wrapper">
<button
id="btn-1cc"
class="rzp-dual-checkout-button checkout-button button alt wc-forward btn-1cc-container"
type="button"
> <div class="button-1cc-wrapper">
<svg width="12" height="15" viewBox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.14321 4.72412L4.47803 7.1758L8.28423 4.71034L5.7951 14.0119L8.32281 14.0142L11.9999 0.275635L5.14321 4.72412Z" fill="#F4F6FE"/>
<path d="M1.04646 10.1036L0 14.0138H5.18124C5.18124 14.0138 7.3005 6.06116 7.30109 6.05884C7.2991 6.06011 1.04646 10.1036 1.04646 10.1036Z" fill="#F4F6FE"/>
</svg>
<span class="button-1cc-text">CHECKOUT WITH RAZORPAY MAGIC</span>
</div>
</button>
<div class="rzp-btn-icon">
<svg width="150" height="20" viewBox="0 0 111 14" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#a)"><path d="M68.865 4.413c-.087.326-.256.565-.507.718-.251.153-.603.23-1.058.23h-1.444l.507-1.895h1.444c.454 0 .766.076.935.229.17.153.21.392.123.718Zm1.496-.04c.183-.686.107-1.213-.229-1.58-.335-.366-.924-.55-1.764-.55h-3.223l-1.94 7.252h1.566l.782-2.923h1.027c.23 0 .411.037.544.112.133.075.21.207.235.397l.279 2.414h1.678l-.272-2.25c-.056-.503-.285-.799-.689-.887a2.96 2.96 0 0 0 1.292-.743 2.71 2.71 0 0 0 .714-1.243Zm3.806 2.525c-.13.489-.332.862-.605 1.12a1.373 1.373 0 0 1-.978.387c-.386 0-.649-.127-.787-.382-.14-.254-.144-.623-.015-1.105.13-.482.335-.859.618-1.13a1.39 1.39 0 0 1 .993-.408c.38 0 .637.131.77.393.133.26.135.636.004 1.125Zm.686-2.566-.196.733a1.151 1.151 0 0 0-.491-.632c-.243-.156-.545-.234-.904-.234-.44 0-.864.114-1.27.341a3.356 3.356 0 0 0-1.067.963 4.205 4.205 0 0 0-.668 1.415c-.142.53-.17.997-.085 1.4.085.405.27.715.554.932.284.218.65.326 1.098.326.359 0 .7-.074 1.026-.224.324-.149.6-.356.827-.621l-.205.764h1.515l1.382-5.163h-1.516Zm6.963 0h-4.403l-.308 1.15h2.563L76.28 8.415l-.29 1.08h4.546l.308-1.15h-2.745l3.439-2.975.278-1.038Zm3.876 2.556c-.136.509-.338.89-.605 1.14a1.36 1.36 0 0 1-.97.377c-.793 0-1.054-.505-.784-1.517.135-.503.338-.881.61-1.136.27-.254.6-.382.986-.382.38 0 .635.128.767.382.132.255.131.633-.004 1.136Zm.887-2.363c-.349-.217-.794-.326-1.337-.326-.549 0-1.057.109-1.526.326-.468.217-.867.53-1.196.937a3.8 3.8 0 0 0-.712 1.426c-.145.543-.162 1.018-.05 1.425.11.408.342.72.694.937.352.218.803.326 1.352.326.542 0 1.046-.108 1.51-.326a3.33 3.33 0 0 0 1.192-.937c.329-.407.566-.882.712-1.425.145-.544.162-1.019.05-1.426a1.545 1.545 0 0 0-.69-.937Zm15.846 2.373c-.131.489-.333.862-.605 1.12a1.372 1.372 0 0 1-.978.387c-.386 0-.649-.127-.787-.382-.14-.254-.144-.623-.015-1.105s.334-.859.617-1.13a1.39 1.39 0 0 1 .994-.408c.379 0 .636.131.77.393.133.26.135.636.004 1.125Zm.686-2.566-.196.733a1.151 1.151 0 0 0-.492-.632c-.243-.156-.544-.234-.903-.234a2.57 2.57 0 0 0-1.271.341 3.356 3.356 0 0 0-1.066.963 4.203 4.203 0 0 0-.669 1.415c-.141.53-.17.997-.084 1.4.085.405.27.715.554.932.284.218.65.326 1.097.326.359 0 .702-.074 1.026-.224.325-.149.6-.356.827-.621l-.204.764h1.515l1.381-5.163h-1.515ZM91.98 5.717l.386-1.406a1.14 1.14 0 0 0-.522-.102 2.08 2.08 0 0 0-1 .26c-.275.149-.51.357-.708.619l.2-.757h-1.514L87.43 9.496h1.536l.722-2.699c.105-.394.294-.7.567-.921.272-.221.612-.331 1.019-.331.25 0 .486.057.706.173Zm4.275 1.201c-.129.482-.329.85-.6 1.105a1.378 1.378 0 0 1-.977.382c-.38 0-.638-.129-.776-.387s-.141-.631-.01-1.12c.13-.49.334-.864.61-1.126.277-.26.606-.392.986-.392.372 0 .626.136.76.408.134.271.136.648.007 1.13ZM97.33 4.54c-.285-.227-.648-.34-1.088-.34a2.4 2.4 0 0 0-1.103.264c-.35.177-.632.417-.85.723l.005-.034.258-.822h-1.5L92.67 5.76l-.012.049-1.575 5.886h1.536l.793-2.963c.077.264.239.472.484.621.245.15.547.224.906.224.447 0 .873-.108 1.277-.326a3.168 3.168 0 0 0 1.052-.932 4.13 4.13 0 0 0 .66-1.4c.142-.53.17-1.001.089-1.415-.082-.415-.266-.735-.551-.963Zm13.654-.207.001-.001h-.93l-.083.001h-.483l-.246.344a1.96 1.96 0 0 0-.061.083l-.027.04-1.962 2.736-.407-3.204h-1.607l.814 4.87-1.797 2.492h1.601l.435-.617.038-.053.508-.722.015-.02 2.274-3.23 1.916-2.717.002-.002h-.001Z" fill="#0F2651"/><path d="m59.258 3.074-.46 1.695 2.631-1.704-1.72 6.428 1.747.002L63.997 0l-4.739 3.074Z" fill="#3395FF"/><path d="m56.427 6.792-.723 2.702h3.58l1.466-5.497c-.002 0-4.323 2.795-4.323 2.795Z" fill="#0F2651"/></g><path d="M12.396 8.855a4.31 4.31 0 0 1-1.228-.166 3.148 3.148 0 0 1-1.005-.499l.404-.744c.285.211.578.364.879.46.3.094.625.142.974.142.396 0 .696-.064.902-.19a.63.63 0 0 0 .309-.562.497.497 0 0 0-.174-.396 1.28 1.28 0 0 0-.444-.262 7.34 7.34 0 0 0-.601-.198 16.019 16.019 0 0 1-.665-.205 2.85 2.85 0 0 1-.61-.301 1.533 1.533 0 0 1-.444-.46c-.11-.184-.166-.417-.166-.696 0-.343.093-.642.277-.895.185-.253.446-.449.784-.586.338-.137.734-.206 1.188-.206.401 0 .779.058 1.132.174.36.116.655.28.887.491l-.396.744a2.672 2.672 0 0 0-.792-.443 2.404 2.404 0 0 0-.855-.158c-.385 0-.683.071-.895.214a.659.659 0 0 0-.316.585c0 .17.055.31.166.42.116.11.266.203.451.277.185.069.388.135.61.198.222.058.443.127.665.206.222.074.425.169.61.285.184.116.332.264.443.443.111.175.166.396.166.666 0 .348-.09.649-.269.902-.18.248-.438.438-.776.57-.338.127-.741.19-1.211.19Zm6.489-.506c-.18.158-.407.282-.681.372-.27.084-.55.126-.84.126-.411 0-.768-.079-1.068-.237a1.68 1.68 0 0 1-.697-.673 2.107 2.107 0 0 1-.246-1.037c0-.439.085-.824.254-1.156.169-.333.404-.592.704-.776a1.942 1.942 0 0 1 1.038-.277c.385 0 .715.084.99.253.274.164.475.406.601.728.132.322.17.713.111 1.172h-2.834l.039-.53h2.257l-.278.142c.032-.343-.031-.604-.19-.784-.158-.184-.374-.277-.649-.277-.348 0-.617.124-.807.372-.185.248-.277.623-.277 1.125 0 .385.092.683.277.894.19.206.467.31.831.31a1.984 1.984 0 0 0 1.235-.42l.23.673Zm2.802.498c-.412 0-.768-.079-1.07-.237a1.63 1.63 0 0 1-.688-.673 2.147 2.147 0 0 1-.238-1.03c0-.453.087-.847.262-1.18.174-.332.422-.588.744-.767.322-.18.702-.27 1.14-.27.317 0 .602.045.855.135.259.09.478.214.657.372l-.34.697a2.264 2.264 0 0 0-.554-.317 1.542 1.542 0 0 0-.578-.11c-.375 0-.665.126-.871.38-.201.253-.301.604-.301 1.053 0 .374.092.665.277.87.19.206.448.31.776.31.211 0 .404-.035.578-.104.18-.073.359-.182.538-.324l.238.697c-.18.158-.396.282-.65.372a2.39 2.39 0 0 1-.775.126Zm3.483 0c-.47 0-.821-.14-1.053-.42-.233-.279-.325-.688-.277-1.227l.182-2.407h.997l-.19 2.344c-.02.312.027.546.143.705.121.153.308.23.562.23.296 0 .528-.096.697-.286.169-.19.266-.446.293-.768l.19-2.225h.982l-.31 3.999h-.973l.063-.816.103.04c-.116.264-.3.47-.554.618a1.686 1.686 0 0 1-.855.213Zm3.268-.055.23-2.866c.015-.185.026-.372.03-.562a6.797 6.797 0 0 0-.007-.57h.934l.032 1.029-.11-.198c.094-.29.268-.517.522-.681a1.554 1.554 0 0 1 1.06-.23.68.68 0 0 1 .183.048l-.071.895a1.52 1.52 0 0 0-.254-.072 1.107 1.107 0 0 0-.269-.031c-.232 0-.43.047-.594.142a.904.904 0 0 0-.364.38 1.386 1.386 0 0 0-.15.554l-.183 2.162h-.99Zm6.507-.443c-.18.158-.407.282-.681.372-.27.084-.55.126-.84.126-.411 0-.767-.079-1.068-.237a1.68 1.68 0 0 1-.697-.673 2.108 2.108 0 0 1-.245-1.037c0-.439.084-.824.253-1.156.169-.333.404-.592.704-.776a1.942 1.942 0 0 1 1.038-.277c.385 0 .715.084.99.253.274.164.475.406.601.728.132.322.17.713.111 1.172h-2.834l.04-.53h2.256l-.277.142c.031-.343-.032-.604-.19-.784-.159-.184-.375-.277-.65-.277-.348 0-.617.124-.807.372-.185.248-.278.623-.278 1.125 0 .385.093.683.278.894.19.206.467.31.831.31a1.983 1.983 0 0 0 1.235-.42l.23.673Zm2.5.498c-.332 0-.627-.076-.886-.23a1.538 1.538 0 0 1-.602-.664 2.367 2.367 0 0 1-.206-1.022c0-.443.077-.831.23-1.164a1.89 1.89 0 0 1 .665-.791c.285-.19.618-.285.998-.285.327 0 .607.073.839.221.232.148.404.357.515.626l-.111.206.214-2.78h.997l-.467 5.828h-.974l.071-1.013.087.237a1.21 1.21 0 0 1-.308.451 1.36 1.36 0 0 1-.475.285c-.18.064-.375.095-.586.095Zm.317-.752a.918.918 0 0 0 .776-.38c.19-.258.285-.604.285-1.037 0-.401-.087-.705-.26-.91-.175-.207-.423-.31-.745-.31a.955.955 0 0 0-.8.38c-.19.254-.285.6-.285 1.038 0 .39.09.691.27.902.179.212.432.317.76.317Zm7.44.752c-.333 0-.615-.07-.847-.213a1.373 1.373 0 0 1-.515-.626l.11-.23-.086 1.014h-.982l.459-5.828h.99l-.222 2.78-.087-.206c.074-.174.177-.325.309-.452.137-.126.295-.224.475-.293.185-.068.383-.102.594-.102.332 0 .625.079.879.237.258.153.459.375.601.665.148.285.222.628.222 1.03 0 .443-.082.834-.245 1.171-.159.333-.38.592-.666.776a1.78 1.78 0 0 1-.99.277Zm-.166-.752a.926.926 0 0 0 .783-.38c.196-.253.293-.602.293-1.045 0-.385-.09-.684-.269-.895-.18-.21-.433-.316-.76-.316a.933.933 0 0 0-.784.388c-.19.253-.285.596-.285 1.029 0 .401.087.705.261.91.18.206.433.31.76.31Zm3.969.958-1.513-4.26h1.006l1.045 3.136-.538 1.124ZM47.5 10.59l-.166-.76c.253-.053.465-.116.633-.19a1.35 1.35 0 0 0 .42-.277c.116-.11.22-.25.309-.42l.261-.475.356-.538 1.529-3.136h.997l-2.217 4.268c-.18.349-.377.626-.593.832-.212.21-.444.37-.697.475-.254.105-.53.18-.832.221Z" fill="#0F2651"/><defs><clipPath id="a"><path fill="#fff" transform="translate(55.705)" d="M0 0h55.281v11.694H0z"/></clipPath></defs></svg>
</div>
</div>

<div id="rzp-spinner-backdrop"></div>
<div id="rzp-spinner">
<div id="loading-indicator"></div>
<div id="icon">
<img src="<?php echo plugin_dir_url(dirname(__FILE__)) . 'public/images/rzp-spinner.svg'; ?>" alt="Loading" id="rzp-logo" />
</div>
</div>
<div id="error-message">
</div>
Loading