Skip to content

Commit 49f7483

Browse files
committed
#313: No price entry unless editing enabled
- Also corrects some PHP Notice/Warning logs from the add-to-order cart class.
1 parent 5d25985 commit 49f7483

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

zc_plugins/EditOrders/v5.0.0/admin/includes/classes/EoCart.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,17 @@ public function addProduct(string $uprid, array $attributes, int|float $qty): ar
232232
$new_product['cart_contents'] = $uprid_contents;
233233
$new_product['is_virtual'] ??= $this->productIsVirtual($new_product, $cart_attributes);
234234

235-
$products_total = zen_add_tax(($qty * $new_product['final_price']) + $new_product['onetime_charges'], $new_product['tax']);
235+
// -----
236+
// Note: 'tax' isn't present for a newly-added product; it'll be calculated (as will total/weight)
237+
// at a later time.
238+
//
239+
$products_total = zen_add_tax(($qty * $new_product['final_price']) + $new_product['onetime_charges'], $new_product['tax'] ?? 0);
236240
$products_weight = $qty * $new_product['products_weight'];
237241

238242
$this->total += $products_total;
239243
$this->weight += $products_weight;
240244

241-
if ($product['is_virtual'] === true || $product['product_is_always_free_shipping'] === 1) {
245+
if ($new_product['is_virtual'] === true || $new_product['product_is_always_free_shipping'] === 1) {
242246
$this->free_shipping_item += $qty;
243247
$this->free_shipping_price += $products_total;
244248
$this->free_shipping_weight += $products_weight;

zc_plugins/EditOrders/v5.0.0/admin/includes/modules/eo_prod_add_modal.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,19 @@
146146
<?= zen_draw_input_field('name', $new_product['name'], 'id="prod-name" class="form-control" ' . $name_params) ?>
147147
</div>
148148
</div>
149-
149+
<?php
150+
// -----
151+
// Determine whether prices and taxes can be manually updated.
152+
//
153+
$price_entry_disabled = ($_SESSION['eo_price_calculations'] === 'Manual') ? '' : 'disabled';
154+
?>
150155
<div class="form-group">
151156
<label class="control-label col-sm-2" for="prod-tax"><?= TEXT_LABEL_TAX ?></label>
152157
<div class="col-sm-10">
153-
<?= zen_draw_input_field('tax', $new_product['tax'], 'id="prod-tax" class="form-control" disabled', false, 'number') ?>
158+
<?= zen_draw_input_field('tax', $new_product['tax'], 'id="prod-tax" class="form-control" min="0" max="100" step="any" ' . $price_entry_disabled, false, 'number') ?>
154159
</div>
155160
</div>
156161
<?php
157-
// -----
158-
// Determine whether prices can be manually updated.
159-
//
160-
$price_entry_disabled = ($_SESSION['eo_price_calculations'] === 'Manual') ? '' : 'disabled';
161-
162162
$final_price = $new_product['final_price'];
163163
$final_price_label = rtrim((DISPLAY_PRICE_WITH_TAX === 'true') ? TABLE_HEADING_UNIT_PRICE_NET : TABLE_HEADING_UNIT_PRICE, ':');
164164
?>

zc_plugins/EditOrders/v5.0.0/admin/includes/modules/eo_prod_update_modal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
<div class="form-group">
182182
<label class="control-label col-sm-2" for="prod-tax"><?= TEXT_LABEL_TAX ?></label>
183183
<div class="col-sm-10">
184-
<?= zen_draw_input_field('tax', $updated_product['tax'], 'id="prod-tax" class="form-control" min="0" max="100" step="any"', false, 'number') ?>
184+
<?= zen_draw_input_field('tax', $updated_product['tax'], 'id="prod-tax" class="form-control" min="0" max="100" step="any" ' . $price_entry_disabled, false, 'number') ?>
185185
</div>
186186
</div>
187187
<?php

0 commit comments

Comments
 (0)