Nordlicht Posted August 4, 2014 Share Posted August 4, 2014 Hi, from an external URL I fill the cart in PS 1.5.4.1 with one item. I use a form like this: <form action="www.shop.com/index.php?controller=cart" method="post"> <p class="hidden"> <input type="hidden" name="id_product" value="2" id="product_page_product_id" /> <input type="hidden" name="add" value="1" /> <input type="hidden" name="id_product_attribute" id="idCombination" value="" /> <input type="hidden" name="qty" id="quantity_wanted" class="hidden" value="1" size="2" maxlength="3" /> <input type="hidden" class="hidden" name="firstname" id="firstname" value="abc" /> <input type="hidden" class="hidden" name="lastname" id="lastname" value="xyz" /> </p> <br /> <input type="image" src="logo_td24_300x64.jpg" alt="Send"></form> At the same time I passed customer's firstname and lastname with the form. The item is createdin the cart, but I can't access customer's name. My question is: in which file I need query thename and how? I want to use it in the shopping-cart.tpl. Does anyone have an idea or tip for me? Thank you Link to comment Share on other sites More sharing options...
vekia Posted August 4, 2014 Share Posted August 4, 2014 action should contain http protocol, action="http://address" instead of just action="www.shop.com/index.php?controller=cart" Quote The item is createdin the cart, but I can't access customer's name. where you want to access customers name? in ps? and what if customer will not be logged in to your shop? Link to comment Share on other sites More sharing options...
Nordlicht Posted August 4, 2014 Author Share Posted August 4, 2014 Hi Vekia, thank you for your quick response! ok, "http" should stand in front of, is unfortunately lost when copying the URL. Yes, I want to access customers name in ps. Background is as follows:Customers buy products in an another shop. There they are logged inand pay and after buying they have to pay transport at another provider.So you click on a link after purchase and come on the side where it issold transportation. This is also a Presta Shop and the products are thetransports. The name and address I know now by buying from the other storeand the customer no longer needs to login. I hope I have made myself clear for the background. Also, I've tried a few things but they did not succeed: In the init function of CartController.php$this-> Tools = testvar :: getValue ('firstName');and thenIn shopping cart.tplTest: {$ cart-> testvar} -> empty / nothing But it doesn't work. How can I read post-informations in shopping-cart.tpl ? Link to comment Share on other sites More sharing options...
Nordlicht Posted August 4, 2014 Author Share Posted August 4, 2014 Hi again, it should read $this->testvar = Tools::getValue('firstame'); not $this-> Tools = testvar :: getValue ('firstName'); Link to comment Share on other sites More sharing options...
vekia Posted August 4, 2014 Share Posted August 4, 2014 can you try to display $_POST variable array? in php file use: var_dump($_POST); does this dump contain variables you POSTED via form? Link to comment Share on other sites More sharing options...
Nordlicht Posted August 5, 2014 Author Share Posted August 5, 2014 Hi Vekia, I've tried it and put var_dump($ _POST) into the file classes\cart.php. The result was that the array is completely empty! But it was created still the right item in Cart. Something MUST have been postet, otherwiseno item is created. Should I try var_dump in another PHP file? Link to comment Share on other sites More sharing options...
Nordlicht Posted August 6, 2014 Author Share Posted August 6, 2014 Hi, ok, I have tested var_dump now in the file classes\controller\FrontController.phpand all information are displayed that have been posted. Then I tried in FrontController.php:$this->context->smarty->assign('testvar', "Hello"); and display in the file shopping-cart.tpl:<div> show me: {$testvar}</div> This works fine. But that doesn't work:$this->context->smarty->assign('testvar', Tools::getValue('firstname'));and$this->context->smarty->assign('testvar', $_POST['firstname']);Both show nothing How can I access the POST variables? 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