<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get specific section or text from URL with request.query in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Get-specific-section-or-text-from-URL-with-request-query/m-p/419483#M21802</link>
    <description>&lt;P&gt;Thanks for the tip&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/118753"&gt;@Ntbrown&lt;/a&gt;.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This is for an integration with Paddle. And this specifically:&amp;nbsp;&lt;A href="https://developer.paddle.com/guides/how-tos/pricing/coupons#using-paddlejs" target="_blank" rel="noopener"&gt;https://developer.paddle.com/guides/how-tos/pricing/coupons#using-paddlejs&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I'm running this JS function to apply my coupon&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;function openCheckout(e) {
  let id = e.getAttribute('data-prod-id');
  let couponGet = e.getAttribute('data-coupon');

  Paddle.Checkout.open({ 
    product: id,
    coupon: couponGet
  });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;BR /&gt;I need to get the "data-coupon" attribute to apply the coupon to the product automatically (this is within our Paddle-generated modal) when the user goes to&amp;nbsp;&lt;A href="http://store.mystore.com/?coupon=xxxxxxxx" target="_blank"&gt;http://store.mystore.com/?coupon=xxxxxxxx&amp;nbsp;&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I belive this would be the actualy URL structure vs the example in my intial quesiton.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;So I need the data-coupon attribute in this example to be "xxxxxxxx"&lt;BR /&gt;&lt;BR /&gt;I'm applying the coupon text to the data-coupon attribute with:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% set path = request.query %}
{% set couponString = path|split('coupon=','2')|last %}

{% set myPlatform = [
  {
    'name': 'UNIVERSAL macOS/WINDOWS',
    'platform': 'Universal',
    'description': 'License works on macOS or Windows',
    'paddleProductId': 12345,
    'coupon': '{{couponString}}'
  },&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;and rendering it in the HTML (with some loops and if statements) with&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; data-coupon = "{{ platform.coupon }}" &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Would your suggestion be a better solution here?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Mar 2021 14:51:46 GMT</pubDate>
    <dc:creator>ckingg</dc:creator>
    <dc:date>2021-03-17T14:51:46Z</dc:date>
  </channel>
</rss>

