Pat114 Posted January 4, 2020 Share Posted January 4, 2020 Hi All, Cart items with customizations do not get removed when pressing the trashcan. Instead, only the customization get's removed. The deletion url also changes to one without 'id_customization'. Items without customizations do work. Because I enabled users to upload .pdf's, I changed some of the code in cart-detailed-product-line.tpl. {if $field.type == 'text'} {if (int)$field.id_module} {$field.text nofilter} {else} {$field.text} {/if} {elseif $field.type == 'image'} <img src="https://img.icons8.com/ios/50/000000/file.png"> {$newUrl = str_replace($field.image.small.url, "_small", "")} <a href="{$newUrl}" target=_blank>Banner Design</a> <!-- <img src="{$field.image.small.url}">--> {/if} (Since I'm a beginner in prestashop, I'm not sure how to get the 'image url' without 'small', so I just cut the string) I also changed some some things in other tpl's in line with product customization, but I'm assuming they are irrelevant to this issue. I don't have any external modules that could be the problem and I'm not getting any errors in the chrome inspector either. ps_shoppingcart.js has not been changed. Thanks in advance for any suggestions or fixes! Link to comment Share on other sites More sharing options...
Pat114 Posted January 6, 2020 Author Share Posted January 6, 2020 Anyone? Link to comment Share on other sites More sharing options...
TCB-Netherlands Posted January 6, 2020 Share Posted January 6, 2020 Well you can check it to use original code of Prestashop, if it works then... Then it is your customization that makes the flaw. Link to comment Share on other sites More sharing options...
Pat114 Posted January 6, 2020 Author Share Posted January 6, 2020 protected function pictureUpload() { if (!$field_ids = $this->product->getCustomizationFieldIds()) { return false; } $authorized_file_fields = array(); foreach ($field_ids as $field_id) { if ($field_id['type'] == Product::CUSTOMIZE_FILE) { $authorized_file_fields[(int) $field_id['id_customization_field']] = 'file' . (int) $field_id['id_customization_field']; } } $indexes = array_flip($authorized_file_fields); foreach ($_FILES as $field_name => $file) { if (in_array($field_name, $authorized_file_fields) && isset($file['tmp_name']) && !empty($file['tmp_name'])) { $file_name = md5(uniqid(mt_rand(0, mt_getrandmax()), true)); /*if ($error = ImageManager::validateUpload($file, (int) Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE'))) { $this->errors[] = $error; }*/ //$product_picture_width = (int) Configuration::get('PS_PRODUCT_PICTURE_WIDTH'); //$product_picture_height = (int) Configuration::get('PS_PRODUCT_PICTURE_HEIGHT'); // $tmp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS'); /* if ($error || (!$tmp_name || !move_uploaded_file($file['tmp_name'], $tmp_name))) { return false; }*/ $extension = substr($file['name'], -3, 3); if ($extension == 'pdf') { $file_name = $file_name.'.'.str_replace('.', '', $extension); if (!move_uploaded_file($file['tmp_name'], _PS_UPLOAD_DIR_.$file_name)) { return false; } chmod(_PS_UPLOAD_DIR_.$file_name, 0777); $this->context->cart->addPictureToProduct($this->product->id, $indexes[$field_name], Product::CUSTOMIZE_FILE, $file_name); } else { $this->errors[] = Tools::displayError('This format is not accepted'); } // unlink($tmp_name); } } return true; } I have overridden the ProductController.php so that is the problem, but I'm not sure why... I've tried many things, but it still deletes just the customization of the item in the cart instead of the item. Even after refresh the item remains in cart. Still no error of any type... Link to comment Share on other sites More sharing options...
Pat114 Posted January 8, 2020 Author Share Posted January 8, 2020 Maybe someone can suggest which other file I need to modify in order for it to work? Link to comment Share on other sites More sharing options...
TCB-Netherlands Posted January 10, 2020 Share Posted January 10, 2020 So far for the image URL, there is no url without small, medium or large. This is the image url for (cover, home and product page) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now