Jump to content

Modifying Products Deselects Digital Option


svrabel

Recommended Posts

It's not a problem that I know of.

 

Even though the file name is in the list (I call it a File Picker), meaning it is probably referenced in the CubeCart_filemanager database table, please verify that the file actually exists where the File Manager says it is. This is just a shot in the dark.

Link to comment
Share on other sites

PHP:
[Notice] /store/classes/request.class.php:255 - cURL Error (22): The requested URL returned error: 404 Not Found

GET:

'_g' => 'products'
'sort' =>
'updated' => 'DESC'
'action' => 'edit'
'product_id' => '304'
 
This is what debug is showing me when I'm in product manager.
Link to comment
Share on other sites

This error comes from the fact that CubeCart may be asking for the RSS feed from a different URL. In admin, Store Settings, Layout tab, Default RSS URL for Admin Dashboard:

http://forums.cubecart.com/rss/forums/1-cubecart-news-announcements/

When you first log in to the admin, CubeCart also makes a request to this URL:

http://cp.cubecart.com/licence/version/X.Y.Z

where X.Y.Z would be 5.2.12, for example. This request is to determine if you are running the latest version.

 

In admin, Request Log, see if the request and 404 response is being logged.

Link to comment
Share on other sites

The cURL error and the cause of the cURL error (probably) has nothing to do with the situation that is causing CubeCart to forget the digital file selection.

 

You may want to submit a Trouble Ticket to Devellion. They should be able to discover why this is happening fairly quickly (but not on the weekends).

Link to comment
Share on other sites

What is somewhat confusing is that you are getting the 404 error notice when you are editing a product. I now see that CubeCart will fetch a list of Google product types when the product is brought up for editing. Please read this conversation. Let us know if it applies to you.

 

Still, this does not explain the reset digital file selection.

Link to comment
Share on other sites

I just dug through the access logs, and it appears that the site isn't finding one of the images (images/menu_top_open.png), but I can't find any mention of it in any of the admin stylesheets. It's just strange. I'll go ahead and submit a trouble ticket.

Link to comment
Share on other sites

I would very much like to have a report of what gets POSTed to CubeCart when editing a product and you click Save. Specifically when having chosen a file to make the product a 'digital' file, yet shows as 'tangible' at some time later. And it is when you make an edit at this later time (no changes to the digital file status) when the 'digital' state is lost.

 

If you need instruction on how to get your browser to show you what was POSTed from the form, let me know.

Link to comment
Share on other sites

I think I found a contributing factor to the problem: the digital file is in a subfolder. That is, when bringing the product up for editing a second time, the digital tab shows a filepicker window listing a folder, and you have to click on that folder (repeat as necessary) to see the actual file in the list.

 

Can you confirm that the digital file assigned to this product is in a folder?

Link to comment
Share on other sites

If so, then one solution (Devellion, please take note) is to make sure the filepicker window (the FileTree jQuery plugin) show the assigned file wherever it may be in the /files/ folder hierarchy - of which there can be only one digital file assigned in the current codebase - instead of having the filepicker start at the default /files/ folder.

Link to comment
Share on other sites

The File Tree jQuery plugin is written specifically so that the filepicker window only records changes to the file assigned to the product. If there are no changes, there will be no POSTing of the 'download' form element. The 'download' form element contains an array of each listed file's FileManager index with either '1' or '0' as enabled. But, again, only if something changes.

 

The current code does not properly handle a missing $_POST['download']. The current code assumes that no POST['download'] means that no file has been assigned (again, it actually means no changes to the choice of file assigned), and resets the product's digital status.

 

It would be nice if the filepicker window could be coded to show the assigned file (especially if the file is in a subfolder), and also perhaps to return the currently assigned file as a POST['digital'] array of key/values.

 

I think the immediate solution is to use the following code. In the file /admin/sources/products.index.inc.php, take note of lines 78 and 100. Those lines and all lines between, comment that range:

Line 78 was:
// Update product
 
Now:
/* // Update product
 
Line 99-100 was:
  $record['digital'] = 0; // no path nor list of files
}
 
Now:
  $record['digital'] = 0; // no path nor list of files
} */

Then add this code just above line 101:

Line 101:
$record['updated'] = date('Y-m-d H:i:s', time());
 
Add above:
if (!empty($_POST['digital_path'])) { // Deal with the one thing that's guaranteed: a non-empty 'digital_path'.
  $record['digital'] = 1; $record['digital_path'] = $_POST['digital_path'];
} else { // Otherwise, deal with the filepicker.
  // When 'download' is not set, the only thing this means is that the filepicker did not register a file choice change.
  // So, we must determine if an assignment is already in the database.
  if (!isset($_POST['download'])) { // So, no file choice changes, now to check if there was a previous assignment.
    if ($old_product_data[0]['digital']) { // There was a previous assignment. Keep it.
      $record['digital'] = $old_product_data[0]['digital'];
    }
  } else { // Otherwise, 'download' is set.
    // The filepicker recorded a change with respect to what file is associated with this product.
    // $_POST['download'] will contain an 'enable' and/or one or more 'disable'.
    // The filepicker records all "changes". We are only interested in the new 'enabled' choice.
    // If there is no new 'enable', 'digital' will remain zero.
    $record['digital'] = 0;
    foreach ($_POST['download'] as $key => $enabled) {
      if ($enabled) { // A file was newly enabled and will be assigned to 'digital'.
        $record['digital'] = $key;
        break;
      }
    }
  }
}
Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...