Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Checkout Process
 
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 09-19-2019, 05:25 AM
 
KarylSampson KarylSampson is offline
    
Join Date: Sep 2019
Posts: 1
 

Default Checkout Process

Hi, Everyone, I want to put add to cart and checkout in https://buyhotellinen.com, Any Suggestion or idea will be helpful, Thanks
__________________
Buy Hotel Linen
Reply With Quote
  #2  
Old 10-02-2019, 09:43 AM
 
Ed B. Ed B. is offline
 

eXpert
  
Join Date: Apr 2016
Posts: 221
 

Default Re: Checkout Process

I looked around and haven't found how to implement such a feature easily. It is quite amazing that nobody has thought about "quick buy" feature...
__________________
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote
  #3  
Old 10-02-2019, 10:51 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 13,597
 

Default Re: Checkout Process

Actually they did - https://market.x-cart.com/addons/buy-button.html
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
Ed B. (10-02-2019)
  #4  
Old 10-03-2019, 08:27 AM
 
Ed B. Ed B. is offline
 

eXpert
  
Join Date: Apr 2016
Posts: 221
 

Default Re: Checkout Process

Well, I don't think it does what OP had in mind. I think OP wants
  • by clicking the button, the customer goes directly to check out page (with the product added to the cart)
  • to put the button on product list (one button for each product)
__________________
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote
  #5  
Old 10-08-2019, 06:21 AM
 
Ed B. Ed B. is offline
 

eXpert
  
Join Date: Apr 2016
Posts: 221
 

Default Re: Checkout Process

I thought this would be a children's game, but somehow I can't make this work.


So my idea is to add a button on ListItem, that is


skins/customer/modules/EdB/QuickBuy/items_list/product/parts/mybutton.twig
Code:
{## # # @ListChild (list="itemsList.product.grid.customer.tail", weight="99") #} {## # # @ListChild (list="itemsList.product.grid.customer.tail", weight="99") #} {{ widget('\\XLite\\Module\\EdB\\QuickBuy\\View\\Button\\Quick') }}
(this will add buttons for every article, even the ones that can't be ordered, but we can deal with this problem later).


The button widget looks like


Code:
<?php namespace XLite\Module\EdB\QuickBuy\View\Button; class Quick extends \XLite\View\Button\Regular /** * Go to checkout */ { /** * Get default label * * @return string */ protected function getDefaultLabel() { return 'Buy'; } protected function getDefaultAction() { return 'quickBuy'; } /** * Define widget parameters * * @return void */ protected function defineWidgetParams() { } /** * getDefaultStyle * * @return string */ protected function getDefaultStyle() { return $this->getCart()->checkCart() ? 'regular-main-button checkout' : 'regular-main-button disabled add2cart-disabled checkout'; }


Again, the button looks terribly ugly, but we can deal with it later. Normally, it only remains to define the function doActionQuickBuy() in the appropriate controller class,
that is


Code:
<?php namespace XLite\Module\EdB\QuickBuy\Controller\Customer; abstract class Cart extends XLite\Controller\Customer\Cart implements \XLite\Ba se\IDecorator { public function doActionQuickBuy() { echo "action!"; parent::doActionAdd(); $this->setReturnURL( $this->buildURL('checkout', '', array()) ); } }
(Probably one could have simply done
Code:
parent::doActionAdd(); parent::doActionCheckout();


However, this code produces the button, but clicking on the button does
nothing. Presumably because the regular button is for submitting a form, and there is no form. I have also tried to use "Link" class, but then I can't define "getDefaultAction". Another approach would be somehow to decorate

View/Product/ListItem.php to get a second button, the class use a method getAdd2CartBlockWidget to show the "add to cart" button, but I fail to see how to use this method to produce another button. or call twice this method within the class.


Would anyone know how to do this?


[added]


Maybe the simplest thing to do is to write a method similar to getAdd2CartBlockWidget in a class decorating ListItem and call it from an appropriate twig, but then where can I define getDefaultAction() or something similar? The getAdd2CartBlockWidget() looks like
Code:
protected function getAdd2CartBlockWidget() { $widget = null; ... $widget = $this->getWidget( [ 'style' => 'add-to-cart product-add2cart productid-' . $this ->getProduct()->getProductId(), 'label' => 'Add to cart', ], 'XLite\View\Button\Simple' ); } return $widget;
and it is some jquery scripts that deals with the action of button. And in the javascript, I haven't seen functions that looks like doActionAddtoCart() that is in the controller.
__________________
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote
  #6  
Old 10-09-2019, 12:04 AM
 
Ed B. Ed B. is offline
 

eXpert
  
Join Date: Apr 2016
Posts: 221
 

Default Re: Checkout Process

I gave up on buttons, instead, I tried
twig file
[code]
{##
#
# @ListChild (list="itemsList.product.grid.customer.tail", weight="99")
#}
<div class="company-logo">
<a href={{ url('cart', 'QuickBuy', { 'param_1': 'some_param_value' }) }}>
Quick Buy</a>
</div>
with Controller class
Code:
public function doActionQuickBuy() { echo "action!"; parent::doActionAdd(); $this->setReturnURL( $this->buildURL('checkout', '', array()) ); }
Then the customer gets redirected to the "checkout page" clicking on the link (provided that the cart is not empty before), but the product isn't added to the cart.
As a matter of fact, if I remove setReturnURL, then nothing happens when the customer clicks on the link. What am I doing wrong here?
__________________
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 05:32 AM.

   

 
X-Cart forums © 2001-2018