EDIT #1: I forgot to mention, I am using Setting repeatable-regions data through cms:db_persist_form concept which mentions:
But I am unable to achieve the same with <cms:db_persist>
Good Evening to All and KK Sir.
I am trying to save data to repeatable region by an ajax call. The data gets saved else where (i have a textarea set to check if data is getting stored), but not in the repeatable region.
My AJAX code is:
And the code for the save-order.php where the AJAX data is collected and saved to Database is:
All data is sent in the ajax call and is saved except for the field data for the repeatable region field: product_in_cart.
My editable for repeatable region are defined as:
The data sent from ajax using "product_in_cart" is saved to the textarea "product_in_cart_json" but not in repeatable region "product_in_cart".
Can you please help me understand where is the issue?
Regards,
GenXCoders (Aashish)
we can also explicitly set them through direct parameters of <cms:db_persist_form> (and its non-DBF counterpart <cms:db_persist>) tag
But I am unable to achieve the same with <cms:db_persist>
Good Evening to All and KK Sir.
I am trying to save data to repeatable region by an ajax call. The data gets saved else where (i have a textarea set to check if data is getting stored), but not in the repeatable region.
My AJAX code is:
- Code: Select all
var cart_data = '[<cms:pp_cart_items>{"ordered_product":"<cms:show id />","ordered_quantity":"<cms:show quantity />","ordered_price":"<cms:number_format price />"}<cms:incr item_count/><cms:if item_count != "<cms:pp_count_unique_items/>">,</cms:if></cms:pp_cart_items>]';
$.ajax({
url: "<cms:show k_site_link />ajax/save-order.php",
type: 'POST',
dataType: 'json',
data: {
user_id: "<cms:show user_id_for_address />",
product_in_cart: cart_data,
order_price: "<cms:show order_price />",
order_payment_status : "Pending"
},
success: function(data){
window.location.href="<cms:link 'delivery-address.php' />?otid="+data+"&op=<cms:show cashout_amount />"
},
error: function(){
console.log("The request failed");
}
});
And the code for the save-order.php where the AJAX data is collected and saved to Database is:
- Code: Select all
<?php require_once( '../couch/cms.php' ); ?>
<cms:template title="Save Address at Checkout" parent="_users_" hidden="1" />
<cms:set user_id_save = "<cms:gpc 'user_id' method='POST' />" "global" />
<cms:set product_in_cart_save = "<cms:gpc 'product_in_cart' method='POST' />" "global" />
<cms:set order_price_save = "<cms:gpc 'order_price' method='POST' />" "global" />
<cms:set order_payment_status_save = "<cms:gpc 'order_payment_status' method='POST' />" "global" />
<cms:if product_in_cart_save ne ''>
<cms:db_persist
_masterpage='order.php'
_mode='create'
_invalidate_cache='0'
_auto_title='0'
k_page_title = "<cms:pages masterpage='users/index.php' id=user_id_save limit='1'><cms:show user_fname /> <cms:show user_lname />-<cms:show user_mobile />-</cms:pages><cms:date format='Y-m-dTH:i:s' />"
user_id = "<cms:show user_id_save />"
order_price = "<cms:show order_price_save />"
order_payment_status = "<cms:show order_payment_status_save />"
product_in_cart_json = "<cms:show product_in_cart_save as_json='1' />"
product_in_cart = "<cms:capture into='my_data' is_json='1'><cms:show_repeatable 'product_in_cart' as_json='1' /></cms:capture ><cms:capture into='my_data.' is_json='1'><cms:show product_in_cart_save as_json='1' /></cms:capture>"
>
<cms:if k_error >
<cms:abort><cms:show k_error /></cms:abort>
<cms:else_if k_success />
<cms:abort>
<cms:show k_last_insert_id />
</cms:abort>
</cms:if>
</cms:db_persist>
</cms:if>
<?php COUCH::invoke(); ?>
All data is sent in the ajax call and is saved except for the field data for the repeatable region field: product_in_cart.
My editable for repeatable region are defined as:
- Code: Select all
<cms:editable name="shippable_product" label="Shippable Product" type="group" order="3" />
<cms:editable name="product_in_cart_json" label="JSON" type="textarea" no_xss_check="1" order="1" group="shippable_product" />
<cms:repeatable name="product_in_cart" label="Order Details" group="shippable_product" order="2" >
<cms:editable name="ordered_product" label="Ordered Product" type="text" order="1" validator="non_negative_integer" />
<cms:editable name="ordered_quantity" label="Ordered Quantity" type="text" order="2" />
<cms:editable name="ordered_price" label="Ordered Price" type="text" order="3" />
</cms:repeatable>
The data sent from ajax using "product_in_cart" is saved to the textarea "product_in_cart_json" but not in repeatable region "product_in_cart".
Can you please help me understand where is the issue?
Regards,
GenXCoders (Aashish)