Is this solution work only for view of commerce products?
I've created view of products display, with field "Commerce Product: Product ID", and one click button not work in this case. After pressing button "Create order" nothing happen.

CommentFileSizeAuthor
#3 buy_one_click.jpg143.19 KBAlex_eav

Comments

Alex_eav created an issue. See original summary.

dragon658’s picture

Hello, Alex!

I did not test commerce_buy_one_click module in view of product displays, but I suspect that it shall work.
Look at "Using buy one click button in views" section of readme.md file.

4. Place the following content into "Text" section of this field:

<div class="commerce-buy-one-click-button-wrapper">
  <div class="commerce-buy-one-click-button-product-id element-hidden">[product_id]</div>
  <div class="commerce-buy-one-click-button-add-product-to-cart element-hidden">1</div>
  <div class="commerce-buy-one-click-button-quantity element-hidden">1</div>
  <a href="#" class="commerce-buy-one-click-button">Buy one click</a>
</div>

Look at [product_id] at line 2 in this code. I suppose that you have to replace [product_id] with your actual product_id from your replace patterns.
Did you do it? Does it help?

Alex_eav’s picture

StatusFileSize
new143.19 KB

Hi Denis,
Yes, I did everything like in your instruction, but maybe, I did something wrong.
See attached file.
I should note that standard button "Buy one click" from your module, work in product display, and don't work in field "Add to Cart" in view. That's why I tried to add in view "Buy one click" according to your instruction, but result was the same like with standard button - I can add data in form but after I've press the button "Create order" nothing happen.

dragon658’s picture

Alex, look at "commerce_buy_one_click.js" file.

This line of code select each html element with "commerce-buy-one-click-button" class on the page. (such elements must be in your view)
Such HTML elements are used as buy one click buttons.

jQuery(".commerce-buy-one-click-button").each(function(index) {
      var clicked_button = jQuery(this);
      ...

This line of code init fancybox for such elements:

clicked_button.fancybox({
            helpers: {
              overlay: {
                locked: false
              }
            },
...

Do you have any ideas why could this JS not work on your site?

I assume that your problem can be triggered by one of the following things:

1. Javascript error on page where your view is placed. Does your page with the view have fatal javascript errors?

2. Do you add your view to your page dinamically? My current code from "commerce_buy_one_click.js" file does not work with dynamically added html elements. (and it it not right - it shall be fixed in the feature)

Could you give me a link to the page with the view?

dragon658’s picture

Alex, please open "commerce_buy_one_click.js" file and replace line 3

jQuery(".commerce-buy-one-click-button").each(function(index) {

with this

jQuery("body").delegate(".commerce-buy-one-click-button", "click", function(index) {

Does it help?

Alex_eav’s picture

Hi Denis,
I have AJAX error on this page.
I made some tests and have additional information.
I'll give you access to my test site and you will see every thing you need.
All needed data and additional information I sent you by message from contacts in your profile.
If you don't receive it give me your contact and I will send it again.

dragon658’s picture

Alex, please send me access data to info@dtec.pro
I cannot find message you sent me with contact form.

Alex_eav’s picture

Done