2 Коммиты ec318c26e2 ... 2315196c3f

Автор SHA1 Сообщение Дата
  Benjamin Harris 2315196c3f CLAUDE changes 2 недель назад
  Benjamin Harris 157de46254 Fix OCMOD tab injection by anchoring on SEO tab and embedding content inline 2 недель назад
3 измененных файлов с 123 добавлено и 44 удалено
  1. 3 1
      .gitignore
  2. 26 0
      CLAUDE.md
  3. 94 43
      install.xml

+ 3 - 1
.gitignore

@@ -1,4 +1,6 @@
 # Ignore the .claude directory
 .claude/
 # Ignore all zip files
-*.zip
+*.zip
+
+OPENCART.md

+ 26 - 0
CLAUDE.md

@@ -138,6 +138,32 @@ Key endpoints:
 | `/webhooks` | POST | Register a webhook endpoint |
 | `/categories/flat` | GET | Get the full Reverb category tree |
 
+
+When creating API in reverb these are the options available.
+
+Scopes allow you to set the permissions of your token.
+| --- | --- |
+| public | Read publicly available data |
+| read_feedback | Read feedback that you have sent or received |
+| read_payouts |  |
+| write_feedback | Write feedback about your transactions on the site |
+| read_listings | Read all of your listings with your sales and bump data |
+| write_listings | Create/update your listings (inventory, price, etc) and add a listing to sales / bump |
+| read_lists | Read your watch list / feed |
+| write_lists | Update your watch list / feed |
+| read_messages | Retrieve your messages |
+| write_messages | Post and update messages as you |
+| read_offers | Read your offers |
+| write_offers | Make offers on listings on your behalf |
+| read_orders | Read all your orders |
+| write_orders | Update the status of your orders |
+| read_profile | Get the details about your account and shop, such as name and email address |
+| write_profile | Update settings for your shop (name, address, vacation, etc) |
+| read_reviews | Read your reviews of listings |
+| write_reviews | Write reviews of listings on your behalf |
+| read_addresses | write_addresses |
+
+
 ## Sync Flow
 
 ### OpenCart → Reverb (triggered on product save event or manual sync)

+ 94 - 43
install.xml

@@ -2,7 +2,7 @@
 <modification>
     <name>Reverb Integration</name>
     <code>reverb</code>
-    <version>1.0.1</version>
+    <version>1.0.2</version>
     <author>Reverb OpenCart</author>
     <link>https://reverb.com/au/page/integrations</link>
 
@@ -15,60 +15,45 @@
     -->
     <file path="admin/controller/catalog/product.php">
 
-        <!--
-            Load per-product Reverb data into $data[] so the Twig template
-            can render the Reverb tab. Targets the final setOutput() call in
-            the shared getForm() method, which is used by both add() and edit().
-        -->
         <operation>
             <search><![CDATA[$this->response->setOutput($this->load->view('catalog/product', $data));]]></search>
             <add position="before"><![CDATA[
-                // Reverb Integration: load per-product Reverb data
                 $this->load->model('extension/module/reverb');
                 $reverb_product_id = isset($this->request->get['product_id']) ? (int)$this->request->get['product_id'] : 0;
                 $reverb_row = $this->model_extension_module_reverb->getProductMap($reverb_product_id);
-                $data['reverb_sync_enabled']         = $reverb_row ? (int)$reverb_row['sync_enabled']         : 0;
-                $data['reverb_condition_uuid']        = $reverb_row ? $reverb_row['condition_uuid']            : '';
-                $data['reverb_category_uuid']         = $reverb_row ? $reverb_row['reverb_category_uuid']      : '';
-                $data['reverb_listing_id']            = $reverb_row ? $reverb_row['reverb_listing_id']         : '';
-                $data['reverb_conditions']            = $this->model_extension_module_reverb->getListingConditions();
-                $data['reverb_oc_category_mappings']  = $this->model_extension_module_reverb->getCategoryMappings();
-                $data['reverb_categories']            = $this->model_extension_module_reverb->getReverbCategories();
+                $data['reverb_sync_enabled']   = $reverb_row ? (int)$reverb_row['sync_enabled']        : 0;
+                $data['reverb_condition_uuid']  = $reverb_row ? $reverb_row['condition_uuid']           : '';
+                $data['reverb_category_uuid']   = $reverb_row ? $reverb_row['reverb_category_uuid']     : '';
+                $data['reverb_listing_id']      = $reverb_row ? $reverb_row['reverb_listing_id']        : '';
+                $data['reverb_conditions']      = $this->model_extension_module_reverb->getListingConditions();
+                $data['reverb_categories']      = $this->model_extension_module_reverb->getReverbCategories();
             ]]></add>
         </operation>
 
-        <!--
-            Save Reverb data after editProduct() is called.
-        -->
         <operation>
             <search><![CDATA[$this->model_catalog_product->editProduct($this->request->get['product_id'], $this->request->post);]]></search>
             <add position="after"><![CDATA[
-                // Reverb Integration: save per-product Reverb data on edit
                 if (isset($this->request->post['reverb_sync_enabled']) || isset($this->request->post['reverb_condition_uuid'])) {
                     $this->load->model('extension/module/reverb');
-                    $this->model_extension_module_reverb->saveProductMap((int)$this->request->get['product_id'], [
+                    $this->model_extension_module_reverb->saveProductMap((int)$this->request->get['product_id'], array(
                         'sync_enabled'         => isset($this->request->post['reverb_sync_enabled']) ? 1 : 0,
-                        'condition_uuid'       => $this->request->post['reverb_condition_uuid']  ?? '',
-                        'reverb_category_uuid' => $this->request->post['reverb_category_uuid']  ?? '',
-                    ]);
+                        'condition_uuid'       => isset($this->request->post['reverb_condition_uuid'])  ? $this->request->post['reverb_condition_uuid']  : '',
+                        'reverb_category_uuid' => isset($this->request->post['reverb_category_uuid'])  ? $this->request->post['reverb_category_uuid']  : '',
+                    ));
                 }
             ]]></add>
         </operation>
 
-        <!--
-            Save Reverb data after addProduct() is called.
-        -->
         <operation>
             <search><![CDATA[$product_id = $this->model_catalog_product->addProduct($this->request->post);]]></search>
             <add position="after"><![CDATA[
-                // Reverb Integration: save per-product Reverb data on add
                 if (isset($this->request->post['reverb_sync_enabled']) || isset($this->request->post['reverb_condition_uuid'])) {
                     $this->load->model('extension/module/reverb');
-                    $this->model_extension_module_reverb->saveProductMap((int)$product_id, [
+                    $this->model_extension_module_reverb->saveProductMap((int)$product_id, array(
                         'sync_enabled'         => isset($this->request->post['reverb_sync_enabled']) ? 1 : 0,
-                        'condition_uuid'       => $this->request->post['reverb_condition_uuid']  ?? '',
-                        'reverb_category_uuid' => $this->request->post['reverb_category_uuid']  ?? '',
-                    ]);
+                        'condition_uuid'       => isset($this->request->post['reverb_condition_uuid'])  ? $this->request->post['reverb_condition_uuid']  : '',
+                        'reverb_category_uuid' => isset($this->request->post['reverb_category_uuid'])  ? $this->request->post['reverb_category_uuid']  : '',
+                    ));
                 }
             ]]></add>
         </operation>
@@ -79,28 +64,94 @@
         ========================================================================
         FILE 2: admin/view/template/catalog/product.twig
         Add a "Reverb" tab to the product edit page.
+        Anchored on the SEO tab (always present in OC3) rather than Design tab
+        to avoid mismatches with customised themes. Content embedded inline to
+        avoid Twig include path resolution issues.
         ========================================================================
     -->
     <file path="admin/view/template/catalog/product.twig">
 
-        <!-- Add tab navigation item after the Design tab -->
         <operation>
-            <search><![CDATA[<li><a href="#tab-design" data-toggle="tab">{{ tab_design }}</a></li>]]></search>
-            <add position="after"><![CDATA[
-                <li><a href="#tab-reverb" data-toggle="tab">Reverb</a></li>
-            ]]></add>
+            <search><![CDATA[<li><a href="#tab-seo" data-toggle="tab">{{ tab_seo }}</a></li>]]></search>
+            <add position="after"><![CDATA[<li><a href="#tab-reverb" data-toggle="tab">Reverb</a></li>]]></add>
         </operation>
 
-        <!--
-            Inject the Reverb tab pane. We include the dedicated template which
-            has access to all $data variables (conditions, category mappings, etc.)
-            loaded above by the PHP patch.
-        -->
         <operation>
-            <search><![CDATA[<div class="tab-pane" id="tab-design">]]></search>
+            <search><![CDATA[<div class="tab-pane" id="tab-seo">]]></search>
             <add position="before"><![CDATA[
-                {% include 'extension/module/reverb_product.twig' %}
-            ]]></add>
+<div class="tab-pane" id="tab-reverb">
+  <div class="panel panel-default" style="margin-top:15px;">
+    <div class="panel-body">
+
+      <div class="form-group">
+        <label class="col-sm-2 control-label">List on Reverb</label>
+        <div class="col-sm-10">
+          <input type="hidden" name="reverb_sync_enabled" value="0" />
+          <label class="checkbox-inline">
+            <input type="checkbox" name="reverb_sync_enabled" value="1"
+                   {% if reverb_sync_enabled %}checked="checked"{% endif %} />
+            Enable sync for this product
+          </label>
+          <p class="help-block">Enable to include this product in Reverb syncs. The product must also be in an allowed category (set in the Reverb module settings).</p>
+        </div>
+      </div>
+
+      <div class="form-group">
+        <label class="col-sm-2 control-label">Condition</label>
+        <div class="col-sm-4">
+          <select name="reverb_condition_uuid" class="form-control">
+            <option value="">-- Select Condition --</option>
+            {% for condition in reverb_conditions %}
+            <option value="{{ condition.uuid }}"
+              {% if reverb_condition_uuid == condition.uuid %}selected="selected"{% endif %}>
+              {{ condition.display_name }}
+            </option>
+            {% endfor %}
+          </select>
+          <p class="help-block">Required by Reverb. Describes the physical state of the item.</p>
+        </div>
+      </div>
+
+      <div class="form-group">
+        <label class="col-sm-2 control-label">Reverb Category</label>
+        <div class="col-sm-6">
+          <select name="reverb_category_uuid" class="form-control">
+            <option value="">-- Use category mapping default --</option>
+            {% for rc in reverb_categories %}
+            <option value="{{ rc.uuid }}"
+              {% if reverb_category_uuid == rc.uuid %}selected="selected"{% endif %}>
+              {{ rc.full_name|default(rc.name) }}
+            </option>
+            {% endfor %}
+          </select>
+          <p class="help-block">Leave blank to use the default mapping from the Reverb module settings.</p>
+        </div>
+      </div>
+
+      {% if reverb_listing_id %}
+      <div class="form-group">
+        <label class="col-sm-2 control-label">Reverb Listing</label>
+        <div class="col-sm-10">
+          <p class="form-control-static">
+            <a href="https://reverb.com/item/{{ reverb_listing_id }}" target="_blank" rel="noopener">
+              <i class="fa fa-external-link"></i> View on Reverb (ID: {{ reverb_listing_id }})
+            </a>
+          </p>
+        </div>
+      </div>
+      {% else %}
+      <div class="form-group">
+        <label class="col-sm-2 control-label">Reverb Listing</label>
+        <div class="col-sm-10">
+          <p class="form-control-static text-muted">Not yet synced to Reverb.</p>
+        </div>
+      </div>
+      {% endif %}
+
+    </div>
+  </div>
+</div>
+]]></add>
         </operation>
 
     </file>