Add Brand and Cost columns to price comparison table
- Brand column (from _brand meta) before SKU - Cost column (from _cost meta) before Your Price - Helps evaluate suggested prices against actual product cost Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -620,8 +620,10 @@ class Informatiq_SP_Admin {
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30px;"><input type="checkbox" id="informatiq-sp-select-all-header"></th>
|
||||
<th><?php esc_html_e( 'Brand', 'informatiq-smart-pricing' ); ?></th>
|
||||
<th><?php esc_html_e( 'SKU', 'informatiq-smart-pricing' ); ?></th>
|
||||
<th><?php esc_html_e( 'Product', 'informatiq-smart-pricing' ); ?></th>
|
||||
<th><?php esc_html_e( 'Cost', 'informatiq-smart-pricing' ); ?></th>
|
||||
<th><?php esc_html_e( 'Your Price', 'informatiq-smart-pricing' ); ?></th>
|
||||
<th><?php esc_html_e( 'Suggested', 'informatiq-smart-pricing' ); ?></th>
|
||||
<th title="<?php esc_attr_e( 'Percentage difference from your price', 'informatiq-smart-pricing' ); ?>">
|
||||
@@ -882,6 +884,11 @@ class Informatiq_SP_Admin {
|
||||
|
||||
$product_id = $product->get_id();
|
||||
|
||||
// Get brand and cost from meta.
|
||||
$brand = $product->get_meta( '_brand', true );
|
||||
$cost = $product->get_meta( '_cost', true );
|
||||
$cost = $cost !== '' ? round( (float) $cost, 4 ) : null;
|
||||
|
||||
// Get local price (tax-inclusive for comparison with Google).
|
||||
$sale_price = $product->get_sale_price();
|
||||
$regular_price = $product->get_regular_price();
|
||||
@@ -913,8 +920,10 @@ class Informatiq_SP_Admin {
|
||||
|
||||
$comparison[] = array(
|
||||
'id' => $product_id,
|
||||
'brand' => $brand ?: '',
|
||||
'name' => $product->get_name(),
|
||||
'sku' => $sku,
|
||||
'cost' => $cost,
|
||||
'local_price' => $local_price_incl_tax ? round( $local_price_incl_tax, 2 ) : null,
|
||||
'price_type' => $price_type,
|
||||
'google_price' => $insight['google_price'] ?? null,
|
||||
|
||||
@@ -300,7 +300,7 @@
|
||||
// Render table rows
|
||||
var html = '';
|
||||
if (pageProducts.length === 0) {
|
||||
html = '<tr><td colspan="10">No products found.</td></tr>';
|
||||
html = '<tr><td colspan="12">No products found.</td></tr>';
|
||||
} else {
|
||||
pageProducts.forEach(function(product) {
|
||||
var localPrice = product.local_price ? data.currency + parseFloat(product.local_price).toFixed(2) : '-';
|
||||
@@ -346,10 +346,14 @@
|
||||
? '<button type="button" class="button button-small informatiq-sp-update-single" data-product-id="' + product.id + '" data-new-price="' + product.suggested_price + '">Update</button>'
|
||||
: (product.has_insight ? '<span style="color:#888;">No suggestion</span>' : '-');
|
||||
|
||||
var costPrice = product.cost !== null ? data.currency + parseFloat(product.cost).toFixed(2) : '-';
|
||||
|
||||
html += '<tr>';
|
||||
html += '<td>' + checkbox + '</td>';
|
||||
html += '<td>' + (product.brand || '-') + '</td>';
|
||||
html += '<td><code style="font-size: 11px;">' + product.sku + '</code></td>';
|
||||
html += '<td><a href="post.php?post=' + product.id + '&action=edit">' + self.truncate(product.name, 35) + '</a></td>';
|
||||
html += '<td>' + costPrice + '</td>';
|
||||
html += '<td>' + localPrice + priceLabel + '</td>';
|
||||
html += '<td>' + suggestedPrice + '</td>';
|
||||
html += '<td style="' + percentDiffStyle + '">' + percentDiffHtml + '</td>';
|
||||
|
||||
Reference in New Issue
Block a user