Dynamic Content: Pick up User Input

Hi!

This may be another one a bit out of scope, but you have been so helpful before, so I figure I could give it a shot. :slight_smile:

I’d like to pick up user form input, and pass it into the button URL.

More specifically, I’d like to dynamically update the quantity in the custom WooCommerce add-to-cart URL:

https://www.shopurl.com/custom-product-page/?add-to-cart=6105&quantity={{dc:post:meta key="custom_cart_quantity"}}

General idea is to have an input field next to the button, or plus/minus buttons, which allow users to choose the quantity of the products, and based on this, the custom add-to-cart url would be updated. There may be multiple of them on the same page.

Thanks!

Hi @Misho,

Thanks for reaching out.

Is this for the admin or the product page? But regardless, I don’t think this needs dynamic content, because as said, the URL is updated as the input value is typed in. That can be achieved by javascript/jQuery onChange or keyUp event, then update the URL.

Dynamic content is only useful if the data is already saved/stored and needs retrieval and processed on different locations at different times. But, it would require custom codes to implement a dynamic content on any of Woocommerce existing feature, example,

https://www.shopurl.com/custom-product-page/?add-to-cart=6105&quantity=<?php echo cs_dynamic_content('{{dc:post:meta key="custom_cart_quantity"}}'); ?>

The cs_dynamic_content() is similar for do_shortcode(), but of course for dynamic content only.

Thanks!

Thanks @rad!

It is for custom Shop page, made with Pro, where only WC shortcodes exist, so I needed to come up with some replacements of the shop/product page functionality. This will of course be much easier once you come out with the Layout editor. :slight_smile:

Thanks again, I’ll try to take it from there. :+1:

You are most welcome!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.