-
Posts
8 -
Joined
-
Last visited
About Strky
- Birthday 07/20/1993
Profile Information
-
Location
Czech
-
Activity
Freelancer
Strky's Achievements
-
Add attachment when order status changes
Strky replied to connectcase's topic in Configuring and using PrestaShop
Hi, maybe you forgot for any tag or something. Try to turn on debug mod and maybe you see error..- 4 replies
-
- attachment
- order
-
(and 1 more)
Tagged with:
-
Round price without decimals after discount
Strky replied to Strky's topic in Ecommerce x PrestaShop [ARCHIVE BOARD]
Hi, what is your prestashop version? -
Maybe I solved this... First, make "firstname" and "lastname" not required. In Customer.php and Address.php: delete 'required' => true, from 'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32), 'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32), Then, in /controllers/front/AddressController.php add in function processSubmitAddress() below protected function processSubmitAddress() { $address = new Address(); $this->errors = $address->validateController(); $address->id_customer = (int)$this->context->customer->id; // Check page token if ($this->context->customer->isLogged() && !$this->isTokenValid()) $this->errors[] = Tools::displayError('Invalid token.'); add this if (Tools::getValue('company') == '') { $nameone = Tools::getValue('firstname'); if(empty($nameone)) $this->errors[] = Tools::displayError('firstname is required'); $nametwo = Tools::getValue('lastname'); if(empty($nametwo)) $this->errors[] = Tools::displayError('lastname is required'); } And the same code add in AuthController.php below protected function processSubmitAccount() { Hook::exec('actionBeforeSubmitAccount'); $this->create_account = true; if (Tools::isSubmit('submitAccount')) $this->context->smarty->assign('email_create', 1); // New Guest customer
-
Add attachment when order status changes
Strky replied to connectcase's topic in Configuring and using PrestaShop
Hi, I found some solutions... In /classes/order/OrderHistory.php Around line 410, is a function that sends mail with pdf only on "payment accepted" if ((int)$result['id_order_state'] === 2 && (int)Configuration::get('PS_INVOICE') && $order->invoice_number) { $context = Context::getContext(); $pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty); $file_attachement['content'] = $pdf->render(false); $file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->id).'.pdf'; $file_attachement['mime'] = 'application/pdf'; } It takes order status by ID. So, under this, add code. elseif ((int)$result['id_order_state'] === 23 && (int)Configuration::get('PS_INVOICE') && $order->invoice_number) { $context = Context::getContext(); $pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty); $file_attachement['content'] = $pdf->render(false); $file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->id).'.pdf'; $file_attachement['mime'] = 'application/pdf'; } And in "elseif ((int)$result['id_order_state'] === 23" -> instead of 23 add your status one ID. So it will look like: (red is old code and green is new) // Join PDF invoice if order state is "payment accepted" if ((int)$result['id_order_state'] === 2 && (int)Configuration::get('PS_INVOICE') && $order->invoice_number) { $context = Context::getContext(); $pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty); $file_attachement['content'] = $pdf->render(false); $file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->id).'.pdf'; $file_attachement['mime'] = 'application/pdf'; } elseif ((int)$result['id_order_state'] === 23 && (int)Configuration::get('PS_INVOICE') && $order->invoice_number) { $context = Context::getContext(); $pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty); $file_attachement['content'] = $pdf->render(false); $file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->id).'.pdf'; $file_attachement['mime'] = 'application/pdf'; } else $file_attachement = null;- 4 replies
-
- attachment
- order
-
(and 1 more)
Tagged with:
-
Round price without decimals after discount
Strky replied to Strky's topic in Ecommerce x PrestaShop [ARCHIVE BOARD]
I tried the solution and here it is... In classes/Product.php add before Group reduction (around rows 2770) // Group reduction if ($use_group_reduction) { $reduction_from_category = GroupReduction::getValueForProduct($id_product, $id_group); if ($reduction_from_category !== false) $group_reduction = $price * (float)$reduction_from_category; else // apply group reduction if there is no group reduction for this category $group_reduction = (($reduc = Group::getReductionByIdGroup($id_group)) != 0) ? ($price * $reduc / 100) : 0; } this code $price = Tools::ps_round($price,0); so the code will look something like $price = Tools::ps_round($price,0); // Group reduction if ($use_group_reduction) { $reduction_from_category = GroupReduction::getValueForProduct($id_product, $id_group); if ($reduction_from_category !== false) $group_reduction = $price * (float)$reduction_from_category; else // apply group reduction if there is no group reduction for this category $group_reduction = (($reduc = Group::getReductionByIdGroup($id_group)) != 0) ? ($price * $reduc / 100) : 0; } But if we want to work only when rounding the decimal number are off, need to add IF. In classes/Currency.php add function under this code (around rows 281) public static function getCurrency($id_currency) { return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT * FROM `'._DB_PREFIX_.'currency` WHERE `deleted` = 0 AND `id_currency` = '.(int)($id_currency)); } add this code public static function getDesonoff($id_decimal) { $id_decimal = Db::getInstance()->getValue("SELECT decimals FROM "._DB_PREFIX_."currency"); return $id_decimal; } And add IF, in to the classes/Product.php to our code add new code with IF if (Currency::getDesonoff($id_decimal) == 0){ $price = Tools::ps_round($price,0); } -
Hello, when I use a discount on the product, get a price with decimals (eg. 716.00> 15%> 608.80), but when I turned off decimals, it shows (608), but the acquisition of two product, show the final price in 1213 instead of 1212. Also, does not change anything if I set the rounding up or down. PS v. 1.6.0.5 Any ideas? All help greatly appreciated...
-
Super, ale ve verzi PS 1.6.0.9 mi to nefungje s kombinacemi. Je to proto že se cena neaktualizuje v js. Po upravě product.js ve /theme/nazev_theme/js/ to funguje správně. Do funkce function updatePrice() pod (u mě to je na řádku 657) $('#our_price_display').text(formatCurrency(priceWithDiscountsDisplay * currencyRate, currencyFormat, currencySign, currencyBlank)); přidáme: $('#our_price_displaybezdane').text(formatCurrency(basePriceWithoutTax * currencyRate, currencyFormat, currencySign, currencyBlank)); A ještě jsem upravil čast kodu od Mortmil, jen jsem ve <span>, ktery zobrazuje cenu bez dph změnil ID na our_price_displaybezdane (může napsat vlatni ID, ale musi se změnit taky v přidanem kodu pro product.js) <p class="our_price_display bezdane" itemprop="offers" itemscope itemtype="http://schema.org/Offer"> <span id="" class="bezdane"> <span id="our_price_displaybezdane">{convertPrice price=$product->getPrice(false, $smarty.const.NULL)}</span> {l s='tax excl.'} </span> </p> Snad pomůže. PS: JS může být v každé šabloně jiný a tohle nemusí funguvat. Jde o to, že je třeba najít funkci v js pro update ceny a přidat funkci pro update naší nově vytvořené ceny.
.png.022b5452a8f28f552bc9430097a16da2.png)