Hey fam,
i was creating a custom app for a store
it is a rewards points app and i was creating the redemption part
i stuck in the redemption part because im not able to alter the cart total value
can someone help me on this
Hi Abhinav,
We’ll need more info from you to troubleshoot this issue, eg:
- What have you tried so far?
- Are you seeing any errors?
- Do you have code snippets you can share?
i have tried some code in liquid
i can retrieve the values from the metafield
but i cannot alter the cart value so that that value is carried onto the checkout page
{%- capture html -%}
<div class="shopping-cart-area mt-100 mb-100" id="section-{{ section.id }}">
<div class="container">
{%- if cart.item_count > 0 -%}
<form action="/cart" method="post" novalidate class="cart">
<div class="row">
<div class="col-lg-12 mb-30">
<div class="cart-table-container">
<table class="cart-table">
<thead>
<tr>
<th class="pro-title product-name" colspan="2">{{ section.settings.table_product_title }}</th>
<th class="pro-price product-price">{{ section.settings.table_price_title }}</th>
<th class="pro-quantity product-quantity">{{ section.settings.table_quantity_title }}</th>
<th class="pro-subtotal product-subtotal">{{ section.settings.table_total_title }}</th>
<th class="pro-remove product-remov"> </th>
</tr>
</thead>
<tbody>
{% for item in cart.items %}
{%- assign InventoryManagement = item.variant.inventory_management -%}
{%- assign inventoryQty = item.variant.inventory_quantity | plus: 0 -%}
{%- unless InventoryManagement -%}
{%- assign inventoryQty = 100000 -%}
{%- endunless -%}
{%- if item.variant.available and inventoryQty == 0 -%}
{%- assign inventoryQty = 100000 -%}
{%- endif -%}
<tr>
<td class="product-thumbnail pro-thumbnail">
<a href="{{ item.url }}">
{%- render 'lazyload_image_src',
image: item,
size: 'compact' -%}
</a>
</td>
<td class="product-name pro-name">
<a href="{{ item.url }}">{{ item.product.title }}</a>
{%- unless item.variant.title contains 'Default' -%}
<span class="product-variation">{{ item.variant.title }}</span>
{%- endunless -%}
{% if section.settings.cart_vendor_enable %}
<p>{{ item.vendor }}</p>
{% endif %}
</td>
<td class="product-price pro-price">
<span class="price amount">{{ item.price | money }}</span>
{%- if item.variant.available and item.unit_price_measurement -%}
<div class="unit-price caption">
<span class="visually-hidden">{{ 'products.product.price.unit_price' | t }}</span>
{{ item.variant.unit_price | money }}
<span aria-hidden="true">/</span>
<span class="visually-hidden"> {{ 'accessibility.unit_price_separator' | t }} </span>
{%- if item.variant.unit_price_measurement.reference_value != 1 -%}
{{- item.variant.unit_price_measurement.reference_value -}}
{%- endif -%}
{{ item.variant.unit_price_measurement.reference_unit }}
</div>
{%- endif -%}
</td>
<td class="product-quantity pro-quantity">
<div class="pro-qty d-inline-block mx-0 pt-0">
<span class="dec">-</span>
<input type="text" name="updates[]" value="{{ item.quantity }}" totalqty="{{ inventoryQty }}" >
<span class="inc" title="{% if inventoryQty < 100000 %}{{inventoryQty}} {{ 'products.product.in_stock' | t }}{% else %}{{ 'products.product.many_stock' | t }}{% endif %}">+</span>
</div>
</td>
<td class="total-price pro-subtotal"><span class="price">{{ item.line_price | money }}</span></td>
<td class="product-remove pro-remove">
<a href="/cart/change?line={{ forloop.index }}&quantity=0"><i class="ion-android-close"></i></a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="col-lg-12 mb-80">
<div class="cart-coupon-area pb-30">
<div class="row align-items-center">
<div class="col-lg-12 text-left text-lg-right">
<input class="renza-button renza-button--medium ml-0" name="update" type="submit" value="{{ section.settings.update_button_title }}" />
<a class="renza-button renza-button--medium" href="{{ routes.all_products_collection_url }}">{{ section.settings.continue_shopping_title }}</a>
<a class="renza-button renza-button--medium" href="{{ routes.cart_clear_url }}">{{ section.settings.clear_cart_title }}</a>
</div>
</div>
</div>
</div>
<div class="col-lg-12 col-12">
<div class="cart-payment">
<div class="row">
<div class="col-lg-12">
<div class="cart-calculation-area">
<h2 class="mb-40">{{ section.settings.cart_total_heading_title }}</h2>
<table class="cart-calculation-table mb-30">
<tbody>
<tr class="cart-subtotal">
<th>{{ section.settings.cart_subtotal_title }}</th>
<td><span class="amount"><span id="bk-cart-subtotal-price">{{ cart.total_price | money }}</span></span></td>
</tr>
<tr class="order-total">
<th>{{ section.settings.cart_total_title }}</th>
<td>
<strong><span class="amount"><span id="bk-cart-subtotal-price">{{ cart.total_price | money }}</span></span></strong>
</td>
</tr>
</tbody>
</table>
{%- if cart.total_discounts > 0 -%}
{% assign savings = cart.total_discounts | money %}
<p>
<span class="cart-subtotal__savings"><em>{{ 'cart.general.savings_html' | t: price: savings }}</em></span>
</p>
{%- endif -%}
<div class="cart-calculation-button text-center">
<button type="submit" class="renza-button renza-button--medium checkout_btn" name="checkout">{{ section.settings.checkout_button_title }}</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
<div class="col-lg-12">
<div class="reward-points-section">
{% if customer %}
{% assign reward_points = customer.metafields.custom.rewardpoints | default: 0 %}
<p>You have <strong>{{ reward_points }}</strong> reward points.</p>
{% assign redeemable_points = 0 %}
{% assign redeemable_value = 0 %}
{% if cart.total_price > 200000 %}
{% if cart.total_price > 1000000 %}
{% assign redeemable_points = reward_points | times: 0.25 %}
{% else %}
{% assign redeemable_points = reward_points | times: 0.15 %}
{% endif %}
{% assign redeemable_value = redeemable_points | floor %}
{% endif %}
{% if redeemable_value > 0 %}
{% assign redeemable_currency = redeemable_value | times:100 %}
<p>You can redeem <strong>{{ redeemable_points | floor }}</strong> points worth <strong>{{ redeemable_currency | money }}</strong> for this purchase.</p>
<label>
<input type="checkbox" id="redeem_points_checkbox" />
Use points for this purchase
</label>
{% else %}
<p>You cannot redeem points for this purchase.</p>
{% endif %}
{% else %}
<p>Log in to view and redeem your reward points.</p>
{% endif %}
</div>
</div>
{%- else -%}
<div class="row">
<div class="col-lg-12 col-12">
<div class="empty-cart-page text-center">
{%- if section.settings.empty_cart_title_bar -%}
<h4 class="empty_cart_title">{{ section.settings.shopping_cart_title }}</h4>
{%- endif -%}
{%- if section.settings.empty_cart_img_enable -%}
<div class="empty__cart_img">
{%- if section.settings.empty_cart_img != blank -%}
{%- render 'lazyload_image_src',
image: section.settings.empty_cart_img,
size: 'master' -%}
{%- else -%}
<img class="lazyload" data-src="https://cdn.shopify.com/s/files/1/0132/3116/1408/files/cart.png?13612" alt="{{ section.settings.empty_cart_img.alt }}" >
{%- endif -%}
</div>
{%- endif -%}
{%- if section.settings.empty_cart_title_enable -%}
<h5 class="mb-30">{{ section.settings.cart_empty_title }}</h5>
{%- endif -%}
{% if section.settings.continue_shoping_enable %}
<p><a class="renza-button renza-button--small" href="{{ routes.all_products_collection_url }}"><i class="fa fa-angle-left" aria-hidden="true"></i> {{ section.settings.cart_continue_title }}</a></p>
{%- endif -%}
</div>
</div>
</div>
{%- endif -%}
</div>
</div>
<!-- PAGE SECTION END -->
{%- endcapture -%}
{{ html | strip_newlines | replace:' ','' | replace:' ','' | replace:' ',' ' }}
{%- render 'section_typography' -%}
<style>
#section-{{ section.id }} .renza-button.renza-button--medium.checkout_btn {
background: {{ section.settings.checkbout_btn_color }};
border-color: {{ section.settings.checkbout_btn_color }};
color: {{ section.settings.checkout_button_text_color }}!important;
}
.cart-table th {
text-align: center;
}
.cart-coupon-area .renza-button {
margin-left: 10px;
}
</style>
<!--[if (gt IE 9)|!(IE)]><!--><script src="{{ 'shopify_common.js' | shopify_asset_url }}" defer="defer"></script><!--<![endif]-->
<!--[if lte IE 9]><script src="{{ 'shopify_common.js' | shopify_asset_url }}"></script><![endif]-->
{% schema %}
{
"name": "Cart Page",
"settings": [
{
"type": "header",
"content": "Table Heading Title"
},
{
"type": "text",
"id": "table_image_title",
"label": "Image Heading Title",
"default": "Image"
},
{
"type": "text",
"id": "table_product_title",
"label": "Product Heading Title",
"default": "Product"
},
{
"type": "text",
"id": "table_price_title",
"label": "Price Heading Title",
"default": "Price"
},
{
"type": "text",
"id": "table_quantity_title",
"label": "Quantity Heading Title",
"default": "Quantity"
},
{
"type": "text",
"id": "table_total_title",
"label": "Total Heading Title",
"default": "Total"
},
{
"type": "text",
"id": "table_reomove_title",
"label": "Remove Heading Title",
"default": "Remove"
},
{
"type": "header",
"content": "Button Title"
},
{
"type": "text",
"id": "update_button_title",
"label": "Update Button Title",
"default": "Update Cart"
},
{
"type": "text",
"id": "continue_shopping_title",
"label": "Continue Shopping Button Title",
"default": "Continue Shopping"
},
{
"type": "text",
"id": "clear_cart_title",
"label": "Clear Cart Button Title",
"default": "Clear Cart"
},
{
"type": "checkbox",
"id": "cart_vendor_enable",
"label": "Show Product Vendor",
"default": false
},
{
"type": "header",
"content": "Pick A Delivery Date",
"info": "-------"
},
{
"type": "checkbox",
"id": "delivery_date_enable",
"label": "Pick Delivery Date & Time Enable ?",
"default": true
},
{
"type": "text",
"id": "pick_delivery_time_title",
"label": "Pick a delivery date title",
"default": "Pick a delivery date and Time"
},
{
"type": "paragraph",
"content": "Delivery Date"
},
{
"type": "checkbox",
"id": "pick_delivery_only_date",
"label": "Pick Delivery Date Enable ?",
"default": true
},
{
"type": "textarea",
"id": "selectweekDays",
"label": "Select WeekDays",
"default": "1, 2, 3, 4, 5",
"info": "Please follow the instructions. Put here 0-6 using comma(,) Example: 1,2,3,4,5 .The number you don't keep, that will be counted over the weekend.The following number of each day: 0-Sun, 1-Mon, 2-Tue, 3-Wed, 4-Thu, 5-Fri, 6-Sat"
},
{
"type": "paragraph",
"content": "Delivery Time"
},
{
"type": "checkbox",
"id": "pick_delivery_time",
"label": "Pick Delivery Time Enable ?",
"default": true
},
{
"type": "paragraph",
"content": "Special Note for the customers"
},
{
"type": "textarea",
"id": "special_note_for_the_customers",
"label": "You can add a note for the customers",
"default": " Pick delivery date and time as you choose. Delivery Time takes place between 12PM - 4PM MON-FRI AND 8AM-11AM SAT."
},
{
"type": "header",
"content": "Cart Note / Shipping Calculator",
"info": "-------"
},
{
"type": "select",
"id": "cart_feature",
"label": "Show Any One",
"options": [
{
"value": "shipping_calculator",
"label": "Shipping Calculator"
},
{
"value": "cart_note",
"label": "Cart Note"
},
{
"value": "both",
"label": "Cart Note & Calculator"
},
{
"value": "none",
"label": "None"
}
],
"default": "shipping_calculator"
},
{
"type": "text",
"id": "shipping_calculator_heading",
"label": "Shipping Calculator Title",
"default": "Get shipping estimates"
},
{
"type": "text",
"id": "shipping_calculator_button_title",
"label": "Shipping Calculator Button Title",
"default": "Calculate shipping"
},
{
"type": "text",
"id": "cart_note_title",
"label": "Cart Note Title",
"default": "Special instructions for seller"
},
{
"type": "header",
"content": "Cart Totals"
},
{
"type": "text",
"id": "cart_total_heading_title",
"label": "Cart Total Heading Title",
"default": "Cart Totals"
},
{
"type": "text",
"id": "cart_subtotal_title",
"label": "Cart Subtotal Title",
"default": "Subtotal"
},
{
"type": "text",
"id": "cart_total_title",
"label": "Cart Total Title",
"default": "Total"
},
{
"type": "header",
"content": "Checkout Button"
},
{
"type": "checkbox",
"id": "check_term_condtion",
"label": "Terms & Condition Button Enable",
"default": true
},
{
"type": "textarea",
"id": "agree_btn_text",
"label": "Check terms and conditions Agree Text",
"default": "I agree with the terms and conditions"
},
{
"type": "text",
"id": "checkout_button_title",
"label": "Checkout Button Title",
"default": "Proceed to Checkout"
},
{
"type": "color",
"id": "checkbout_btn_color",
"label": "Checkout Button Color",
"default": "#d3122a"
},
{
"type": "color",
"id": "checkout_button_text_color",
"label": "Checkout Button Text Color",
"default": "#fff"
},
{
"type": "header",
"content": "Cart Empty"
},
{
"type": "paragraph",
"content": "Empty Title Bar"
},
{
"type": "checkbox",
"id": "empty_cart_title_bar",
"label": "Empty Shopping Heading Bar",
"default": true
},
{
"type": "text",
"id": "shopping_cart_title",
"label": "Shopping Cart Title",
"default": "Shopping Cart is Empty."
},
{
"type": "paragraph",
"content": "Empty Cart Image"
},
{
"type": "checkbox",
"id": "empty_cart_img_enable",
"label": "Empty Cart Image Enable",
"default": true
},
{
"type": "image_picker",
"id": "empty_cart_img",
"label": "Empty Cart Image",
"info": "Recommended Size: 250 x 250 px"
},
{
"type": "paragraph",
"content": "Empty Cart Title"
},
{
"type": "checkbox",
"id": "empty_cart_title_enable",
"label": "Empty Cart title Enable",
"default": true
},
{
"type": "text",
"id": "cart_empty_title",
"label": "Cart Empty Title ",
"default": "You have no items in your shopping cart."
},
{
"type": "paragraph",
"content": "Continue Shopping Button"
},
{
"type": "checkbox",
"id": "continue_shoping_enable",
"label": "Continue Shopping Button Enable",
"default": true
},
{
"type": "text",
"id": "cart_continue_title",
"label": "Continue Browsing Title",
"default": "Continue Shopping"
}
],
"blocks": [
{
"type": "section_margin",
"name": "Section Margin",
"limit": 1,
"settings": [
{
"type": "header",
"content": "Large/Desktop Device"
},
{
"type": "range",
"id": "section_margin_top",
"min": 0,
"max": 150,
"step": 5,
"label": "Margin Top",
"unit": "px",
"default": 130
},
{
"type": "range",
"id": "section_margin_bottom",
"min": 0,
"max": 150,
"step": 5,
"label": "Margin Bottom",
"unit": "px",
"default": 130
},
{
"type": "header",
"content": "Tablet Device"
},
{
"type": "range",
"id": "section_margin_top_md",
"min": 0,
"max": 150,
"step": 5,
"label": "Margin Top",
"unit": "px",
"default": 90
},
{
"type": "range",
"id": "section_margin_bottom_md",
"min": 0,
"max": 150,
"step": 5,
"label": "Margin Bottom",
"unit": "px",
"default": 90
},
{
"type": "header",
"content": "Mobile Device"
},
{
"type": "range",
"id": "section_margin_top_xs",
"min": 0,
"max": 150,
"step": 5,
"label": "Margin Top",
"unit": "px",
"default": 70
},
{
"type": "range",
"id": "section_margin_bottom_xs",
"min": 0,
"max": 150,
"step": 5,
"label": "Margin Bottom",
"unit": "px",
"default": 70
}
]
},
{
"type": "section_padding",
"name": "Section Padding",
"limit": 1,
"settings": [
{
"type": "header",
"content": "Large/Desktop Device"
},
{
"type": "range",
"id": "section_padding_top",
"min": 0,
"max": 150,
"step": 5,
"label": "Padding Top",
"unit": "px",
"default": 0
},
{
"type": "range",
"id": "section_padding_bottom",
"min": 0,
"max": 150,
"step": 5,
"label": "Padding Bottom",
"unit": "px",
"default": 0
},
{
"type": "header",
"content": "Tablet Device"
},
{
"type": "range",
"id": "section_padding_top_md",
"min": 0,
"max": 150,
"step": 5,
"label": "Padding Top",
"unit": "px",
"default": 0
},
{
"type": "range",
"id": "section_padding_bottom_md",
"min": 0,
"max": 150,
"step": 5,
"label": "Padding Bottom",
"unit": "px",
"default": 0
},
{
"type": "header",
"content": "Mobile Device"
},
{
"type": "range",
"id": "section_padding_top_xs",
"min": 0,
"max": 150,
"step": 5,
"label": "Padding Top",
"unit": "px",
"default": 0
},
{
"type": "range",
"id": "section_padding_bottom_xs",
"min": 0,
"max": 150,
"step": 5,
"label": "Padding Bottom",
"unit": "px",
"default": 0
}
]
}
]
}
{% endschema %}
this is the current code
i have been work on it so the logic to alter cart is not here
it would be really helpfull if someone can tell me what to do
i heard the shopify plus plan allow to edit checkout page but im not in a plus plan