safa Posted February 22, 2016 Share Posted February 22, 2016 (edited) Hello Everyone, this tool showing some content for display in a CMS page (Customer name, e-mail, cart produsct etc..) {SHOP_NAME} -- > Shop Name. {CustomerName} -- > Customer Name. {CustomerLastName} -- > Customer Lastname. {CustomerEmail} -- > Customer E-mail Adress {CartID} -- > Cart ID {CartTotal} -- > Cart Total {CurrencyISO} -- > Currency ISO {Date} -- > Current Date {delivery_block_html} -- > Delivery Adress {invoice_block_html} -- > Invoice Adress {Products} -- >Cart Products List Download Athacded file and upload /override/controllers/front After Delete this file /cache/class_index.php and just write your cms page like this. "Hello {CustomerName} " // override START if ($this->context->customer->isLogged()){ $cart = $this->context->cart; $currency = new CurrencyCore($cart->id_currency); $customer = new Customer((int)$cart->id_customer); $delivery = new Address( $cart->id_address_delivery ); $invoice = new Address( $cart->id_address_invoice); $user = $delivery->getFields(); function _getFormatedAddress(Address $the_address, $line_sep, $fields_style = array()) { return AddressFormat::generateAddress($the_address, array('avoid' => array()), $line_sep, ' ', $fields_style); }; $product_list ='<table><tr><td>Product Name</td><td>Product Price</td><td>Quantity</td><td>Tax</td>'; foreach ( $cart->getProducts() as $key=>$item ) { $price = round( $item['price'], 3 ); if ( $item['price'] > $price ) $price += 0.001; $product_list .= "<tr><td>".$item['name'].'</td>'; $product_list .= "<td>".$price.'</td> '; $product_list .= "<td>".$item['quantity'].'</td> '; $product_list .= "<td>".$item['rate']. "</td></tr>"; } $product_list .='</table>'; if (isset($this->cms)){ $this->cms->content=str_replace("{SHOP_NAME}",configuration::get('PS_SHOP_NAME'),"{$this->cms->content}"); $this->cms->content=str_replace("{CustomerName}",$customer->firstname,"{$this->cms->content}"); $this->cms->content=str_replace("{CustomerLastName}",$customer->lastname,"{$this->cms->content}"); $this->cms->content=str_replace("{CustomerEmail}",$customer->email,"{$this->cms->content}"); $this->cms->content=str_replace("{CartID}",$cart->id,"{$this->cms->content}"); $this->cms->content=str_replace("{CartTotal}",floatval(number_format($cart->getOrderTotal(true, 3), 2, '.', '')),"{$this->cms->content}"); $this->cms->content=str_replace("{CurrencyISO}",$currency->iso_code,"{$this->cms->content}"); $this->cms->content=str_replace("{Date}",gmdate('Y-m-d H:i:s'),"{$this->cms->content}"); $this->cms->content=str_replace("{delivery_block_html}",_getFormatedAddress($delivery, '<br />', array( 'firstname' => '<span style="font-weight:bold;">%s</span>', 'lastname' => '<span style="font-weight:bold;">%s</span>' )),"{$this->cms->content}"); $this->cms->content=str_replace("{invoice_block_html}",_getFormatedAddress($invoice, '<br />', array( 'firstname' => '<span style="font-weight:bold;">%s</span>', 'lastname' => '<span style="font-weight:bold;">%s</span>' )),"{$this->cms->content}"); $this->cms->content=str_replace("{Products}",$product_list,"{$this->cms->content}"); [spam-filter] // override END Regards... CmsController.php Edited February 22, 2016 by safa (see edit history) 1 Link to comment Share on other sites More sharing options...
razaro Posted February 22, 2016 Share Posted February 22, 2016 This is very nice, could be very useful. Thanks for sharing. 1 Link to comment Share on other sites More sharing options...
Rhobur Posted February 24, 2016 Share Posted February 24, 2016 Very nice! It could probably be extended with other Smarty vars :-) 1 Link to comment Share on other sites More sharing options...
safa Posted February 25, 2016 Author Share Posted February 25, 2016 Very nice! It could probably be extended with other Smarty vars :-) thanks , yes you can add any ohet variable like this. Link to comment Share on other sites More sharing options...
ifs-net Posted January 31 Share Posted January 31 On 2/22/2016 at 10:55 PM, safa said: Hello Everyone, this tool showing some content for display in a CMS page (Customer name, e-mail, cart produsct etc..) {SHOP_NAME} -- > Shop Name. {CustomerName} -- > Customer Name. {CustomerLastName} -- > Customer Lastname. {CustomerEmail} -- > Customer E-mail Adress {CartID} -- > Cart ID {CartTotal} -- > Cart Total {CurrencyISO} -- > Currency ISO {Date} -- > Current Date {delivery_block_html} -- > Delivery Adress {invoice_block_html} -- > Invoice Adress {Products} -- >Cart Products List Download Athacded file and upload /override/controllers/front After Delete this file /cache/class_index.php and just write your cms page like this. "Hello {CustomerName} " CmsController.php 8.33 kB · 63 downloads Hello, The code crashed cms pages of prestashop 1.7.8. Can I ask help for the correct code for prestashop 1.7.8 cos pages pls 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