Skip to content

Case 05 / OpenCart 3 / BAS integration

How we fixed stock and pricing by shoe size in an OpenCart–BAS integration

The stock feed arrived on schedule, yet a shoe store sold unavailable sizes and showed a UAH 1,690 item at UAH 3,230. We followed the same offers from the BAS inventory system through CommerceML to the cart and the next scheduled import.

Size 42 stock
3 units corrected to 0
Checked cart price
UAH 3,230 corrected to UAH 1,690
Verification
Order, reservation and the next stock import

Orders were coming in for shoe sizes the warehouse could not supply

An online shoe retailer used OpenCart 3 for its storefront and BAS for inventory, retail prices and order processing. Shoppers chose a size on the product page. Each size had its own offer in BAS, its own available quantity and, for some models, its own price. Stock and prices traveled from BAS to the store. Orders went back the other way.

Managers reported two problems. Customers could order sizes that had sold out, while some sizes still in stock appeared unavailable. On other orders, selecting a size produced a cart price well above the agreed retail price. Files continued to arrive, and the exchange log marked the sessions as successful. The discrepancies persisted across subsequent imports.

While we investigated, staff manually confirmed the price and availability of affected sizes before confirming purchases. They set aside existing disputed orders for individual review. We kept the live order history intact and traced the affected variants before changing catalog values.

We matched actual orders to the corresponding BAS offers

We started with orders where a manager had confirmed a discrepancy. For each one, we recorded the model, SKU, selected size, quantity, unit price, order time and status. We then matched those details to the offer, stock movements and reservations in BAS. A quantity visible in the warehouse today cannot, on its own, tell us what was available when the customer ordered.

For one model, the storefront still showed three units of size 42 even though the captured BAS export already specified zero. Size 43 on the same model also retained an outdated quantity. We identified the exact import batch containing these offers so we could compare its values with the rows changed by that run.

The price discrepancy was a separate control. The product’s base price in OpenCart was UAH 1,540. The agreed retail price of the selected variant in BAS was UAH 1,690. The cart showed UAH 3,230 for that line item, excluding delivery and other order charges. We checked the currency, unit of sale, tax basis, customer group and applicable pricing rules. Discounts and specials did not account for this difference.

Two discrepancies that survived a completed import
ControlSource valueStorefront before the fix
Stock for size 420 units in BAS and in the received XML3 units available
Retail price of the checked variantUAH 1,690 for the selected sizeUAH 3,230 for the item in the cart

Products without size options updated correctly in our control sample. The failures were concentrated on product pages linked to several BAS offers. That narrowed the investigation to variant matching and the way the importer applied stock and prices.

We followed one complete file from BAS to OpenCart

The store used a CommerceML module with custom PHP integration code. In this installation, offers, quantities and prices arrived together in offers.xml. We checked the composition of the actual exchange. No separate price or inventory file subsequently overwrote the values under investigation.

The offers used a combination of the BAS model identifier and its variant characteristic. A label such as “Size 42” was shared across many models and could not identify a sellable item by itself.

In the preserved XML, size 42 carried zero, size 43 had its current quantity, and UAH 1,690 belonged to the expected offer and retail price type. BAS calculated stock available to sell across the two agreed warehouses, already allowing for reservations. Summing physical stock again or deducting those reservations a second time on the website would have changed the meaning of the quantity.

We compared the sent and received files, the exchange session and the handler log. The XML parsed in full and contained the affected offers. We found no interrupted transfer, parser failure or competing import in that session that explained the discrepancies. We could now follow the correct figures into the catalog writer.

One PHP handler was writing two different fields incorrectly

We used an isolated copy with the same module version and customizations and replayed the saved XML. We disabled connections back to the live BAS system, customer emails and other actions that could affect real orders. We traced the writes to the parent product and the individual option value in OpenCart.

Stock was written at the wrong level

The handler located the parent product from the shared part of an external identifier. It updated the product quantity but missed the row for the selected size. Successive offers for a model could overwrite the same parent quantity with different sizes’ stock. That figure therefore ceased to represent the model’s combined availability.

Size 42 retained its previous three units even after a zero arrived. On other products, an incorrect parent quantity could prevent customers from buying a size whose own quantity was positive. We compared these records with what the product page, cart and checkout actually allowed.

The importer added an entire retail price to the base price

BAS supplied the final price for the variant. The custom handler wrote that amount into a standard OpenCart option as a positive adjustment. OpenCart then added UAH 1,690 to the UAH 1,540 base, producing UAH 3,230 in the cart. On this regular retail model, the correct adjustment was UAH 150.

A comparison with the previous implementation showed where the variant-level mapping had been lost. Running the same file reproduced both incorrect writes. Preventing the writes stopped the corruption but also left the sizes without updates. The repair therefore had to restore matching and convert the source values correctly.

How a valid file produced two storefront errors
  1. StockThe handler updated the model. The size row kept its old quantity.
  2. PriceThe handler stored the full retail price as a positive option adjustment.
  3. Customer impactA sold-out size remained available, and the checked cart price included the base twice.

We restored the link between a BAS offer and one OpenCart size

We rebuilt the mapping from the external BAS offer identifier to its OpenCart product, the size option and the exact product_option_value row. We verified it against SKUs, characteristics and the model to which the size belonged. Table names here omit the store-specific prefix.

How an incoming offer reached one size
StageIdentity check
BAS offerIdentify the model and its characteristic using the supplied external identifiers.
OpenCart productConfirm that the target product matches the expected SKU and model.
Size optionCheck that the selected option belongs to that product.
Option valueUpdate the specific product_option_value row for that size.

We checked that two different offers could not silently resolve to one option row. Changed identifiers and ambiguous matches were flagged for review. The importer did not create speculative options or write to a similar-looking product. Once the links were restored, we re-imported the control offers and verified which rows changed.

A zero quantity had to reach the selected size

For each matched size, the importer applied the absolute available quantity supplied by BAS. An explicit zero updated that size to zero. A missing offer in a valid incremental batch meant that the batch contained no new quantity for that size.

For the affected group, size was the only stock-bearing option. We recalculated parent availability from all active sizes of the model. A partial update therefore included the other sizes’ current quantities in the parent total, even though their rows were absent from that file.

We checked that a size selection was required, reviewed the option’s stock-subtraction setting and the store’s out-of-stock checkout policy. We followed an order into the configured statuses that actually triggered a stock deduction. Adding a product to a cart or merely creating an order record did not establish that deduction had occurred.

Size 42 across the repaired exchange
BAS availableReceived XMLOpenCart beforeOpenCart after
0030

After the correction, size 42 could no longer pass normal checkout. For an available size, the option quantity and the parent quantity both decreased at the configured transition. These were two catalog records reflecting one purchase. BAS needed one stock movement for the purchased quantity.

We recalculated option adjustments whenever the base price changed

We kept the agreed source of the model’s base price and the confirmed absolute retail price for each offer. The adjustment for a size was its target price less the current base. OpenCart stored the magnitude and the applicable plus or minus prefix. Equal prices produced a zero adjustment. A lower-priced size used a minus prefix with a positive magnitude to avoid subtracting twice.

The checked variant at two different base prices
ScenarioBase priceOption adjustmentCart unit price
Before the fixUAH 1,540+ UAH 1,690UAH 3,230
After the fixUAH 1,540+ UAH 150UAH 1,690
Base changed on the test copyUAH 1,600+ UAH 90UAH 1,690

A base-price change affected every size on the product. When a partial file omitted some variant prices, we used their last confirmed absolute prices to recalculate the dependent adjustments. If an amount was unavailable, we held that product’s price set for review. Treating a missing price as zero, or publishing a new base with old adjustments, would have generated new errors.

We used the same currency, tax basis and agreed rounding rules throughout, then checked the final line price in the cart. Discounts and specials can change the price to which OpenCart applies an option adjustment. We reviewed those groups separately. The figures above apply to the checked regular retail configuration.

An order acknowledgement and a stock reservation were separate events

Once quantity writes reached the right size, a timing issue still mattered. Between exchange runs, the store could accept a new order. A BAS export produced before that order’s reservation could restore units already committed locally. We reviewed the return flow for orders and the integration’s custom local stock adjustment.

We followed a specific order line, its BAS offer and the quantity through three events. First, the store accepted the order for fulfillment. Then BAS received the order document. Finally, the store accepted a BAS stock snapshot whose available quantity already included the reservation. The acknowledgement of the document did not establish that the current export already reflected it.

Applying a reservation once across two systems
Point in the exchangeTreatment of the local stock adjustment
Local order accepted before the BAS stock figures reflect its reservationKeep the local deduction when applying a new absolute quantity.
BAS acknowledges the order documentCheck which stock snapshot is being applied. The acknowledgement alone does not release the adjustment.
Store accepts quantities that already include this reservationRelease the corresponding local adjustment so the same units are not deducted a second time.
Order state and snapshot cannot be matched reliablyHold that quantity for reconciliation.

We checked cancellation separately. OpenCart could return local stock at a different time from the release of the BAS reservation. A local cancellation did not by itself establish that the warehouse had released the units. We followed order, export, reservation, next stock import and cancellation on the isolated setup. Periodic synchronization still leaves a time window between channels competing for the last pair.

Partial, repeated and damaged batches needed different handling

A valid incremental file updates only the fields and offers it carries. Missing sizes retained their confirmed values, with outstanding local orders taken into account. For a full export, we also checked its agreed coverage. An omitted offer could be treated as a deletion only where the exchange contract explicitly defined that behavior.

We validated the structure before applying a batch. A damaged or incomplete file could not become a completed catalog update. If a structurally valid file contained one unmapped offer, the error was recorded against that offer. No values were written to a neighboring size. A product with an incomplete set of dependent prices could not be marked as successfully repriced.

We recorded the identity of an applied batch. Delivering it again did not reapply its stock effects. This mattered if the storefront had accepted an order after the original run. Replaying the earlier quantity would otherwise put committed stock back on sale.

We also checked ordering. A lock prevents overlapping writers, but a file arriving later can still contain older data. The integration used sequence information from the exchange to establish which values were newer. The server file timestamp alone could not establish that. A batch of uncertain order could not overwrite newer confirmed values automatically.

We retested the original orders and the failure conditions

We started with the same offers that had exposed the defects. After a full run, we checked the external identifier, option row, quantity, base price and adjustment, then verified the product page, cart and checkout. We sent separate changes to stock, variant price and model base price to see what happened to the other sizes on the same product.

Acceptance checks on the isolated copy
ScenarioEvidence we required
Full importControl offers matched their own rows, and the selected variant produced the expected cart result.
Valid partial updateA zero reached the intended size. Omitted sizes kept their confirmed quantities, and the parent total stayed consistent.
Change to the base priceThe checked absolute price stayed at UAH 1,690, including the change to a UAH 1,600 base.
Repeat delivery and damaged XMLA replay did not reapply stock movements. A damaged file did not become a successful catalog update.
Order and reservationThe chosen size and quantity reached the BAS order, and the local adjustment was released against the corresponding stock data.
CancellationLocal stock return and the BAS reservation release were reconciled at the configured status transitions.

A subsequent scheduled exchange was part of acceptance. A one-off correction to a product row could otherwise have looked successful until the next routine import overwrote it.

We deployed the integration changes and kept current orders intact

Before deployment, we backed up the current files, settings, database and offer mappings. We paused new exchange jobs and waited for active sessions to finish. This kept the old and corrected handlers from writing at the same time.

We transferred the integration changes and confirmed mappings. The test database was never needed to replace the live one. We reconciled outstanding order transfers and local stock changes before applying fresh BAS data so that orders accepted during the work remained accounted for.

After resuming the exchange, we checked that the corrected handler actually ran and verified the stored and displayed values. We returned to the original sizes, including zero and positive quantities, checked the selected price and cart line, and observed the next scheduled run. Live orders, descriptions, photographs, categories and existing SEO URLs were preserved.

Existing orders with disputed amounts were reviewed individually

Repairing the catalog corrected availability and pricing for new orders. Earlier purchases needed a separate review. For each disputed order, we reconciled the selected size, recorded amount, payment, reservation and fulfillment status against stock movements at the time of the purchase.

Managers handled fulfillment decisions for orders placed against unavailable sizes. For a pricing discrepancy, we distinguished an incorrect recorded order total from an amount actually charged. These records alone did not establish a financial loss on every order.

We kept the historical order prices. Any adjustments, refunds and related documents remained separate decisions for the owner and authorized staff. Correcting the import did not trigger a fresh stock deduction or a retroactive rewrite of an order.

The log now distinguishes a delivered file from applied data

We separated receipt, parsing and application in the exchange log. Each session recorded matched offers, rejected records, reasons for rejection and the time of the most recent confirmed update. A session with unapplied offers no longer presented the whole catalog as current.

For the control products, we added checks on size quantities and prices and a signal for overdue confirmed updates or broken mappings. We documented the rules for incremental files, dependent pricing and reservations so future changes to the integration could be tested against the same behavior.

Size 42 went out of stock and the checked price returned to UAH 1,690

The BAS values in the investigated cases were correct on arrival. The PHP handler had written inventory at the wrong level and interpreted a full retail price as an option surcharge. Correcting these two writes, their mappings and the reservation logic resolved the discrepancies seen by customers.

Size 42 changed from three units to zero on the storefront and could no longer complete normal checkout. The checked variant’s cart price changed from UAH 3,230 to UAH 1,690. It remained UAH 1,690 when the test base moved from UAH 1,540 to UAH 1,600. The original offers and a subsequent routine exchange provided the verification.

The confirmed result covers the products and order paths tested. Earlier disputed purchases remained available for individual review. No sales uplift or financial recovery figure was established.

Questions about an OpenCart and BAS exchange

Why can a successful exchange still leave quantities wrong?

The session may confirm that XML was received and parsed. We compared a BAS offer’s identifier and quantity with the exact OpenCart size row and the quantity available in checkout after the import.

Why could a customer order a size whose BAS quantity was zero?

The zero arrived but only the parent product was updated. The size retained its old stock. The option-level deduction and out-of-stock checkout settings also needed to be checked.

Why did choosing a size increase the cart price so sharply?

In the standard option pricing used here, OpenCart adds or subtracts an adjustment from the product price. The handler supplied the entire retail price as a positive adjustment. The cart then added that amount on top of the base.

What happens if the base price changes in a partial export?

Every dependent option adjustment needs recalculating against a confirmed absolute price. If the missing prices cannot be recovered reliably, the new price set should remain pending review.

How did you avoid deducting stock twice after an order reached BAS?

We retained the local adjustment until the store accepted available stock that already accounted for that order’s reservation. Receiving an order document and including its reservation in an export are distinct events.

Would re-importing the file have fixed the store?

With the original handler it reproduced the error. After repairing the mapping and calculations, we used a controlled import and a subsequent regular exchange to verify the storefront.

Which tests matter beyond the first corrected product?

We checked zero and positive stock, price and base-price changes, cart totals, order processing, stock return on cancellation and reservations. Full and partial imports, replays, incomplete files and existing disputed orders each needed their own check.

Does your stock feed disagree with the storefront?

Send the store URL and one example with the product, size, expected quantity or price and what the cart actually shows. An anonymized example is enough to begin.

Discuss an integration issue