Skip to content

Commit 92d205c

Browse files
committed
Merge branch 'OFW-299' into release
2 parents 5f9e13d + 4ff01b9 commit 92d205c

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

public/assets/js/public.js

+33
Original file line numberDiff line numberDiff line change
@@ -722,4 +722,37 @@ document.addEventListener("DOMContentLoaded", function (event) {
722722
});
723723
}
724724
});
725+
726+
document.addEventListener('DOMContentLoaded', function () {
727+
document.getElementById('common-click-to-pay').addEventListener('click', function () {
728+
var checkboxes = document.querySelectorAll('.offer-checkbox:checked');
729+
var urls = [];
730+
731+
checkboxes.forEach(function (checkbox)
732+
{
733+
var productUrl = checkbox.getAttribute('data-url');
734+
var offerId = checkbox.getAttribute('data-offer-id');
735+
var offerUid = checkbox.getAttribute('data-offer-uid');
736+
737+
var url = productUrl + (productUrl.indexOf('?') !== -1 ? '&' : '?') +
738+
'__aewcoapi=1&woocommerce-offer-id=' + offerId +
739+
'&woocommerce-offer-uid=' + offerUid;
740+
urls.push(url);
741+
});
742+
743+
if (urls.length > 0) {
744+
function redirectToNext(index) {
745+
if (index < urls.length) {
746+
window.location.href = urls[index];
747+
setTimeout(function () {
748+
redirectToNext(index + 1);
749+
}, 2000);
750+
}
751+
}
752+
redirectToNext(0);
753+
} else {
754+
alert('Please select at least one offer.');
755+
}
756+
});
757+
});
725758
}(jQuery));

public/views/my-offers.php

+12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
'offer_quantity' => __('Quantity', 'offers-for-woocommerce'),
1212
'offer-status' => __('Status', 'offers-for-woocommerce'),
1313
'offer-action' => __('Action', 'offers-for-woocommerce'),
14+
'offer_checkbox' => __('Select', 'offers-for-woocommerce'),
1415
));
1516

1617
$customer_offers = get_posts(apply_filters('ofw_my_account_my_offers_query', array(
@@ -195,6 +196,13 @@
195196
break;
196197
}
197198
}
199+
break;
200+
case 'offer_checkbox' :
201+
if ($post_status === 'accepted-offer') {
202+
$offer_url = $offer_args['product_url'] . (strpos($offer_args['product_url'], '?') ? '&' : '?') . '__aewcoapi=1&woocommerce-offer-id=' . esc_attr($post_id) . '&woocommerce-offer-uid=' . esc_attr($offer_args['offer_uid']); ?>
203+
<input type="checkbox" class="offer-checkbox" name="offer_select[]" value="<?php echo esc_attr($post_id); ?>" data-url="<?php echo esc_url($offer_url); ?>" data-offer-id="<?php echo esc_attr($post_id); ?>" data-offer-uid="<?php echo esc_attr($offer_args['offer_uid']); ?>">
204+
<?php }
205+
break;
198206
}
199207
}
200208
?>
@@ -206,6 +214,10 @@
206214
?>
207215
</tbody>
208216
</table>
217+
218+
<div class="pay-button-wrapper">
219+
<button id="common-click-to-pay" class="button"><?php _e( 'Click to Pay', 'offers-for-woocommerce' ); ?></button>
220+
</div>
209221
<?php else : ?>
210222
<h2 class="entry-title"><?php _e( 'No Offers found', 'offers-for-woocommerce' ); ?></h2>
211223
<?php endif;

0 commit comments

Comments
 (0)