X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   General questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=66)
-   -   Checkout Process (https://forum.x-cart.com/showthread.php?t=77179)

KarylSampson 09-19-2019 05:25 AM

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

Ed B. 10-02-2019 09:43 AM

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...

cflsystems 10-02-2019 10:51 AM

Re: Checkout Process
 
Actually they did - https://market.x-cart.com/addons/buy-button.html

Ed B. 10-03-2019 08:27 AM

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)

Ed B. 10-08-2019 06:21 AM

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.

Ed B. 10-09-2019 12:04 AM

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?


All times are GMT -8. The time now is 08:13 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.