Problems, need help? Have a tip or advice? Post it here.
15 posts Page 1 of 2
Hi, KK!
I have a product which color is defined by a relation editable.
I would like to pass color to cart/cart-modal. I tried to define pp_color as empty editable, but had no luck setting it programmatically to pass to cart.

Is it that the only option is a cms:related_pages call, to find out color by page id?

Second question, please, how to find a page if it's masterpage is unknown? This also relates to cart, as I have products from 2 templates added at the same time to 1 cart. Looking for the right color for the product can lead me to tun <cms:templates><cms:pages> cycle, i suppose (hope, erroneously). Thanks.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Hi trendoman :)

Is it that the only option is a cms:related_pages call, to find out color by page id?
I think that should be a viable option. Using the page-id we can get hold of all data for the page (including the related page, as in your case).

I have products from 2 templates added at the same time to 1 cart
Ok, I'll confess this is news to me :) I don't think I had envisaged using multiple templates for the products.

I think, you could try hardcoding the template's name as a 'pp_' editable region so that it becomes available for use later.
KK wrote: Ok, I'll confess this is news to me :) I don't think I had envisaged using multiple templates for the products.

I think, you could try hardcoding the template's name as a 'pp_' editable region so that it becomes available for use later.

Thank you, KK!

This way should not be rare. Selling cars and car accessories at the same time, for example. Folders within one template can't help much, as we can not relate pages within one template now.

Check my solution! My setup should be comfortable. A product has a reverse_related nested gallery for accessories (color variations in my case). Advantages are - 0) nice placement, main products are not mixed in admin panel with variations, 1) bulk upload of ton of products by photo upload option, 2) I also run a CSV importer 2 times - a. Create mode to prepare colors name list in a third template, b. Edit mode to Sort out all those previously uploaded pictures to their folders and establish 2 kind of relations (main and accss both to color and access to main) and then I delete pages-pics, which are not presented in CSV. This way database is always clean of orphans.
Basically, this is my inventory management way.


BTW, regarding inventory management. I read one of your posts with ideas about incomplete purchases in paypal. Let me add also something doable regarding stocks management. Maybe someone would also read this and consider. Inventory management question is asked once in a while.
--
When you' d be creating a solution for couch pls consider this scenario. Payment is done via other methods, which can take time (WesternUnion, Check clearance etc.). If payment is due, product must be booked to not oversell. Even paypal users can get back to paypal to pay later, idk this for paypal, but similar systems do this with outstanding orders.
SO
/
One way or another, there can be applied a system of buffer time, during which the stock is reduced, and goods are put 'on hold'. And after a set period of time are 'released' to stock again. Can be manual or programmed.
/
This solution enables reducing stock everytime someone goes to paypal to buy. This way no apologies for other buyers. If paypal transaction is abandoned, stock is back and available.
This is clearly working for small amounts of goods and is better than substracting stock only ofter recieved clearance from paypal.

edit: PS. 'On hold' is already doable with one product setting a publishing date in future. Multiple options require a separate editable.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Ok, I defined this editable for both templates and it works perfectly! Leaving post here for others.

Code: Select all
<cms:editable type='text' order='5000'               name='pp_mastertemplate' >
      <cms:show k_template_name />
      </cms:editable>   
      
<cms:editable type='message' order='6000'            name='admin_hacks' >
      <style>
      #k_element_pp_mastertemplate {display:none;}
/* styling can be done in one editable, unless you have something else to hide, heheh */
      </style>
      </cms:editable>
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Very useful suggestions, @trendoman. Thank you.
Welcome.

KK, I almost completed the cart and now testing everything.

With 2 templates for products, I list them and encountered such situation:
Add a product from 1st template and cannot add from another.
Empty cart (ajax) without refreshing list and can add product from 2nd template. Can not add from 1st.
I have thoroughly inspected my code and seems nothing is wrong.

Then I realized that couch passes only pp_id with hidden submit. And, somehow, template_id is not updated.

This is the code from addons/cart/cart.php
Code: Select all
  function add_item(){
            global $FUNCS, $DB;

            if( isset($_POST['pp_id']) && $FUNCS->is_non_zero_natural($_POST['pp_id']) ){

                $item_number = (int)$_POST['pp_id'];
                $rs = $DB->select( K_TBL_PAGES, array('id', 'template_id'), "id = '".$DB->sanitize( $item_number )."'" );


Basically, I want to pass also template_id along that hidden input. Will it help and how to do it?
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Continue investigation..

I'm simply speechless of the tricks my code shows.
I'm in page view. Generated source code is this (stripped from most html):
Code: Select all
<form action="http://elithome.ru/cart-modal.php?kcart_action=1" method="post" accept-charset="utf-8" class="cart-form">
             <input type="hidden" name="pp_id" value="785" style="display:none;">
             <a href="http://elithome.ru/catalog.php?p=785" ></a>
<input name="qty" type="number" step="1" value="1" title="">
<input type="submit" value="Add">
</form>

<form action="http://elithome.ru/cart-modal.php?kcart_action=1" method="post" accept-charset="utf-8" class="cart-form">
            <input type="hidden" name="pp_id" value="790" style="display:none;">   
            <a href="http://elithome.ru/color.php?p=790" ></a>

<input name="qty" type="number" step="1" value="1" title="">
<input type="submit" value="Add">
</form>
   

<form action="http://elithome.ru/cart-modal.php?kcart_action=1" method="post" accept-charset="utf-8" class="cart-form">
               <input type="hidden" name="pp_id" value="791" style="display:none;">
               <a href="http://elithome.ru/color.php?p=791" ></a>

<input name="qty" type="number" step="1" value="1" title="">
<input type="submit" value="Add">
</form>


First product (A) comes from 1st template, two others (B,C) from 2nd template (reverse_related nested gallery to 1st template, but this is irrelevant info, i guess). I can add A and then I can add C. If I add B - it is not added, but the quantity of the A is updated in cart!!
I can empty cart and add B first. Adding C - no problem. Adding A - B is updated in quantity.
What the heck? Idk.

Please, help.. If you need to take a look first hand, I will prepare setup on ftp (i will try to do it fast, but it is not easy, coz will need to translate to english and strip stuff).
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Ok, this is not resolved yet, but a totally fresh setup, that i just did, shows that everything is added kinda normally.
If you want, check it here (http://site100.ru/client/test) I put a test product and 3 colors.
Damn, something must be corrupt, but idk where. Well, i'm off to find The Bug) At least, I know it's on my side.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Same k_page_names. That's the issue.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
I have been debugging /addons/cart/cart.php

BTW, this is the way I do it:
Code: Select all
function dump() {    $message = "";
    foreach (func_get_args() as $var) {
        $message .= print_r($var, true). " ";    }
    error_log($message);}
unlink('C:/Cloud/OpenServer/userdata/logs/PHP-5.3_error.log');   
dump($arr_sort_keys);


Afaik, When I add problematic product to cart, cart is updated in quantity for the previously added product (with same k_page_name)

Then we come to Line360, cart.php:
Code: Select all
// create the sorting key - page_name + attributes
$sorting_key = $FUNCS->make_key( $arr_sort_keys );
// create a unique id for this item. Will be passed on for future actions on cart.
$unique_key = md5( $sorting_key );

What basically happens here is that a unique key is created from k_page_name. My product doesn't come with attributes, so dump of $arr_sort_keys only shows k_page_name. It is therefore what comes out to create a not unique $unique_key.

Pretty much logical, that we now see this action:
// if item already exists in cart, update the original else add a new item.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
15 posts Page 1 of 2