You are here:  » Add to Optional during registration plus 2 other issues


Add to Optional during registration plus 2 other issues

Submitted by Brice on Sat, 2018-01-13 21:50 in

1.Sorry I am slowly working my way through this. New information is I started over. I am finding out its the optional field I added for UPC. If I remove that option then things seems to function ok.

So anytime I add this line to the config.advanced:

$config_fieldSet["upccode"] = "UPC";

the Register and Trial Import results in zero no matter what fields I populate. I remove that line and everything goes back to normal.

2.Another wall I am hitting is I added and Optional field for a stock qty and functions just fine but not visible on the frontend. I am trying to get it to show in the :
|Stockist| Catalogue| Product Name| Price| as seen on the frontend.

3. I am trying to follow the post below but when I check the feeds register step 2 php there is not one line in that php that has (isset($_POST["user_brand"])?$_POST["user_brand"]:"") for me to replace :

In admin/feeds_register_step2.php look for the following code at line 285:

field_custom("Brand","brand",FALSE);
$skipFields = array("category","brand","name","buy_url","price");
...and REPLACE with:

field_custom("Brand","brand",FALSE);
field_custom("Keywords","keywords",FALSE);
$skipFields = array("category","brand","name","buy_url","price","keywords");
Next, look for the following code at line 62:

(isset($_POST["user_brand"])?$_POST["user_brand"]:"")
...and REPLACE with:

(isset($_POST["user_brand"])?$_POST["user_brand"]:""),
(isset($_POST["user_keywords"])?$_POST["user_keywords"]:"")

Submitted by support on Sun, 2018-01-14 11:40

Hello Brice and welcome to the forum!

Re 1;

I notice from your first post regarding custom fields "qty_available" and "upc_code" that you had used underscore however in this case there is no underscore so just in case that is where the problem has arose; if you make sure that in config.advanced.php that you now have:

  $config_fieldSet["qty_available"] = "Quantity Available";
  $config_fieldSet["upc_code"] = "UPC Code";

And then rather than have to run a separate dbmod.php script for each field, the following is a "universal" version that will run the queries to add any custom fields configured in $config_fieldSet to the database:

<?php
  
require("includes/common.php");
  
$config_databaseDebugMode FALSE;
  
$ignore = array("name","description","image_url","buy_url","price","category","brand");
  foreach(
$config_fieldSet as $field => $v)
  {
    if (
in_array($field,$ignore)) continue;
    
$sql "ALTER TABLE `".$config_databaseTablePrefix."feeds`
              ADD `field_"
.$field."` VARCHAR(255) NOT NULL";
    
database_queryModify($sql,$result);
    
$sql "ALTER TABLE `".$config_databaseTablePrefix."products`
              ADD `"
.$field."` VARCHAR(255) NOT NULL";
    
database_queryModify($sql,$result);
  }
  print 
"Done.";
?>

Now, if you do still find that you can't register and trial import a feed; database debug mode should help - enable at line 6 of config.advanced.php:

  $config_databaseDebugMode = TRUE;

Then try the process again, and if it is down to a database problem the MySQL error message should be displayed. If you're not sure from the output, or if there is no difference of course, let me know and I'll check it out further with you...

Re 2;

For example, to add qty_available to the price comparison table, edit html/prices.php and first to add the header row, look for the following code at line 27:

          <th><?php print translate("Price"); ?></th>

...and REPLACE with:

          <th>Quantity Available</th>
          <th><?php print translate("Price"); ?></th>

And then look for the following code at line 59:

            <td class='pt_pr_price'><?php print tapestry_price($product["price"]); ?></td>

...and REPLACE with:

            <td class='pt_pr_price'><?php print $product["qty_available"]; ?></td>
            <td class='pt_pr_price'><?php print tapestry_price($product["price"]); ?></td>

Re 3;

Apologies for the confusion, the only field with the "user_" prefix is the custom version of the merchant name (where not selected as a field). For category and brand, the custom values are held in `category` and `brand` respectively and similarly your custom field would be `keywords` continuing the above example, so the code to look for at line 62 is actually;

          (isset($_POST["brand"])?$_POST["brand"]:"")

...and REPLACE with:

          (isset($_POST["brand"])?$_POST["brand"]:""),
          (isset($_POST["keywords"])?$_POST["keywords"]:"")

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Brice on Mon, 2018-01-15 19:29

Thank You David! I now have issue 1 & 2 resolved.

Problem 3 still persists for me.

Just to make sure I am explaining correctly let me walk through again.

During registration, Optional fields has a Category and Brand option where you cant enter a custom entry or select from available fields. Id like to do this for my optional field.

In the db I have pt_feeds: user_shipping & field_shipping (likely me trying to make something happen)

under pt_product I have: shipping

on my Optional Fields page its labeled Ship Charge and I have a drop down to choose from available fields.

I have done a few combos but I believe this should have worked:
(isset($_POST["brand"])?$_POST["brand"]:""),
(isset($_POST["shipping"])?$_POST["shipping"]:"")

Submitted by support on Tue, 2018-01-16 10:03

Hello Brice,

Your database changes sound fine, and I think most of the following is already in place but just to go through the changes for custom field shipping (enter manually or select a field) modifications would be as follows;

Edit admin/feeds_register_step2.php and look for the following code at line 62:

          (isset($_POST["brand"])?$_POST["brand"]:"")

...and REPLACE with:

          (isset($_POST["brand"])?$_POST["brand"]:""),
          (isset($_POST["shipping"])?$_POST["shipping"]:"")

And then the following code at (now) line 286:

  field_custom("Brand","brand",FALSE);
  $skipFields = array("category","brand","name","buy_url","price");

...and REPLACE with:

  field_custom("Brand","brand",FALSE);
  field_custom("Shipping","shipping",FALSE);
  $skipFields = array("category","brand","name","buy_url","price","shipping");

Edit includes/admin.php and look for the following code at line 2:

  function admin_register($filename,$format,$merchant,$fieldMerchant,$registerFields,$userCategory,$userBrand)

...and REPLACE with:

  function admin_register($filename,$format,$merchant,$fieldMerchant,$registerFields,$userCategory,$userBrand,$userShipping)

...and then the following code at line 63:

                    user_brand='%s'

...and REPLACE with:

                    user_brand='%s',
                    user_shipping='%s'

...and then the following code at (now) line 75:

                    database_safe(tapestry_normalise($userBrand))

...and REPLACE with:

                    database_safe(tapestry_normalise($userBrand)),
                    database_safe(tapestry_normalise($userShipping))

(in the above 2 mods, notice the addition of the comma after the original code)

And finally the following code at (now) line 180:

    if ($admin_importFeed["field_category"])

...and REPLACE with:

    if ($admin_importFeed["field_shipping"])
    {
      if (isset($record[$admin_importFeed["field_shipping"]]))
      {
        $importRecord["shipping"] = $record[$admin_importFeed["field_shipping"]];
      }
      else
      {
        $importRecord["shipping"] = "";
      }
    }
    elseif($admin_importFeed["user_shipping"])
    {
      $importRecord["shipping"] = $admin_importFeed["user_shipping"];
    }
    else
    {
      $importRecord["shipping"] = "";
    }
    if ($admin_importFeed["field_category"])

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Brice on Tue, 2018-01-16 16:38

Appreciate you David!