Skip to content

Commit

Permalink
discount bug + atomic operations
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaiCraciun88 committed Oct 9, 2024
1 parent 4a45930 commit 4016f7c
Show file tree
Hide file tree
Showing 3 changed files with 275 additions and 237 deletions.
13 changes: 13 additions & 0 deletions src/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ public function get_data_info_array() {
return $data;
}

public function select_for_update() {
global $wpdb;
$order_table = self::get_orders_table_name();
$id = (int) $this->get_id();
$sql = "SELECT id FROM `{$order_table}` WHERE id={$id} FOR UPDATE";
return $wpdb->get_row($sql);
}

public static function get_order_by_proforma($seriesName, $number) {
global $wpdb;
if ($seriesName === '' || $number === '') {
Expand Down Expand Up @@ -82,6 +90,11 @@ public static function get_meta_table_name() {
return self::custom_tables_enabled() ? OrdersTableDataStore::get_meta_table_name() : $wpdb->postmeta;
}

public static function get_orders_table_name() {
global $wpdb;
return self::custom_tables_enabled() ? OrdersTableDataStore::get_orders_table_name() : $wpdb->posts;
}

public static function get_meta_table_field_name() {
return self::custom_tables_enabled() ? 'order_id' : 'post_id';
}
Expand Down
8 changes: 4 additions & 4 deletions view/components/order_details_invoice_box.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
var buttons = $('.oblio-generate-<?php echo $options['docType']; ?>'),
deleteButton = $('.oblio-delete-<?php echo $options['docType']; ?>'),
responseContainer = $('#oblio_order_details_box .oblio-ajax-response');
buttons.click(function(e) {
buttons.on('click', function(e) {
var self = $(this);
if (self.hasClass('disabled')) {
return false;
Expand All @@ -96,7 +96,7 @@
if ('link' in response) {
buttons
.not(self)
.hide()
.hide();
self
.attr('href', response.link)
.removeClass('oblio-generate-<?php echo $options['docType']; ?>')
Expand All @@ -114,12 +114,12 @@
}
});
});
deleteButton.click(function(e) {
deleteButton.on('click', function(e) {
e.preventDefault();
var self = $(this);
if (self.hasClass('disabled')) {
return false;
}
e.preventDefault();
self.addClass('disabled');
jQuery.ajax({
dataType: 'json',
Expand Down
Loading

0 comments on commit 4016f7c

Please sign in to comment.